-1

1) I am building a software same as Boojam incident reporter.In that the incidents are recorded from an iphone and send it to the server.

2) After capturing all required information the reporter is suppose to click the send button in the iphone.

3) The data should be send to the database server in the school or organisation.

4) What I required is ,to know what are the technology available to transfer the data from iPhone to server.

Scope is simply I have to send the collected data in an Apple iphone to a server.I use Python language for logic.

Want to know what are the current technology used to perform the same.

Can any one list me technology about this link.

Alireza Savand
  • 3,462
  • 3
  • 26
  • 36
Monk L
  • 3,358
  • 9
  • 26
  • 41

3 Answers3

2

You need to create a web service on your server. The iphone will "upload" the data to this webservice.

There are many ways to do this in Python, and it depends if you are using a web development framework or not. You really should use one. The popular ones are django and flask for this sort of task.

On the iOS side, you will need to use NSURLRequest to post data to the server.

Community
  • 1
  • 1
Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
2

Generally from the your app you build what you need, serialize into json and pass it through your api. This is a sample I have but it talks to a server and gets back a simple sentence. This is just meant to illustrate how some of this is done in xcode. (This is for asking and receiving data, but you get the idea from it)

Below are the .h and .m files.

//Step 1, add NSURLConnectionDataDelegate
        //.h
    @interface ViewController : UIViewController<NSURLConnectionDataDelegate>
    @property (strong, nonatomic) IBOutlet UILabel *answer;
    @end




#import "ViewController.h"

@interface ViewController ()
{//step 2 local data objects
    NSMutableData*webData;
    NSURLConnection*connection;

}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    //Step 8 call (send) the request
    [self getData];
    // Do any additional setup after loading the view, typically from a nib.


    //NSDictionary*dict=[NSJSONSerialization se]
}
//Step 3 implement this method 
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
    [webData setLength:0];
}

//Step 4 append the connection data to your object
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
    [webData appendData:data];
}

//Step 5 Process results from request (called automatically when the data arrives)
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
    //Main parse

    //Web data

    NSError*error;

    //Dictionary serialized (processed) using JSON (Way of encoding data from a web request)
    NSDictionary*data=[NSJSONSerialization JSONObjectWithData:webData options:0 error:&error];

    //If data is nil, then print error
    if (data==nil) {
        NSLog(@"%@",error);
    }

    //Print the data
    NSLog(@"%@",data);

    //Get the numerical result from the dictionary key name
    NSNumber*num=[data valueForKey:@"name"];

    //Convert number to string
    NSString*label=[num stringValue];

    //Set the label to this result
    _answer.text=label;

}
//Step 7, actually initialize the request
-(void)getData{
    //I will break this down as if it where a generic method
    //Connect to the index.php file via this URL


    //Localhost/tutorials is the XAMPP folder on your computer

    //index.php is the php file

    //getLabel(int number){}
    //?f=getLabel (calling this method in the php file)

    //number=900
    //&value=900 is the parameter
    NSURL*url=[NSURL URLWithString:@"http://localhost/tutorials/index.php?f=getLabel&value=900"];

    //In the php file it does number*number and returns the results

    //URL request
    NSURLRequest*request=[NSURLRequest requestWithURL:url];

    //Set the connection
    connection = [NSURLConnection connectionWithRequest:request delegate:self];

    if (connection) {
        webData=[[NSMutableData alloc]init];
    }

    //*****Results of this request are processed by step 5

}//Step 6, in case data connection fails
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
    NSLog(@"fail");

}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
William Falcon
  • 9,813
  • 14
  • 67
  • 110
  • may i know any particular technology behind this.Any technology name is available If so please give me sir – Monk L Mar 27 '13 at 13:33
  • This is from your app. You use objective-C language to build the app (in Xcode provided by apple). Then this file in your app uses Apple NSURLRequest api .and JSON (using apple's JSON api). On the other side (server) of your request, you use what you need. This particular example talks to a php file – William Falcon Mar 27 '13 at 13:39
2

The only technology you need would be JSON for sending/receiving collected data, And at django side you need to implement an API to allow your django application be able to send/receive such a request. You can use django-piston or django-tastypie to create API(s).

Alireza Savand
  • 3,462
  • 3
  • 26
  • 36
  • one doubt,JSON technology is used to send/receive data from iphone, is it right or wrong – user2086641 Mar 27 '13 at 16:05
  • @user2086641 You mean is Apple use it officially to build built-in iPhone apps? I don't know since they don't like to open-source their applications, Anyway `JSON` is the best option for data transmission, Because it have wide variety of support between language libraries and devices. – Alireza Savand Mar 27 '13 at 16:24
  • Apple provides NSJsonSerialization for exactly this reason. Json easily converts into NSDictionary or NSArray Objects that can then be read/used. It also works both ways so you can easily convert an NSDictionary or NSArray to a Json string that can be POSTed to a server. – Kenrik March Mar 27 '13 at 16:44
  • you are right,i got some idea to do – Monk L Mar 28 '13 at 08:03