background - Local notification to poll server at interval (iOS 7) -


I have an NSTimer in iOS, which for every data line in the table based on the voting on a database server every 10 seconds Voting is a fixed data id, which is sent as a logic via PHP-script if the data ID matches the Data ID of the row that is inserted by an external source, then the notification from the app data line Containing a warning box and NSTimer Will stop to be.

But it only works, while the app is running in the foreground and I want to show the notification message as a local alert so that the user exits the app, it will still vote When the app is running in the background well.

I have read on many sites that the Local Notification Service and Background Forbank is the right kind of solution, but I do not know how to actually set it, it is very misleading. Because I have seen many examples where local notifications are used to send reminders to certain dates on calendar and triggers alarms at certain times and not much about voting on a server.

How do you establish a local notification that will vote for a server at a distance of 10 seconds and then as soon as it receives the right type information, will it display it ultimately?

Even how far have I done so far ... NSTimer * confirmedTimer; Int ORD = 1; ... - (IBAction) sendButton: (ID) sender {confirmTimer = [NSTimer scheduled timer with time interval: 10.0 target: auto selector: @sillector (confirmation tick) user information: zero repeats: yes]; } - Tick (void) confirmed {NSString * paramsConfirmed = [NSString stringWithFormat: @ "order_id =% d", orderId]; NSData * postDataConfirmed = [parameter confirmation data is encoding: NSUTF8StringEncoding]; NSURL * url has been confirmed [NSURL URLWithString: @ "http://www.serverexample.com/confirmed.php"]; NSMutableURL request * Confirmed confirmation = [NSMutableURL request request withURL: url confirmed]; [Requested confirmation HTTTP method: @ "post"]; [requestconfirmed addValue: @ "application / x-www-form-urlencoded" forHTTPHeaderField: @ "content-type"]; [Requested HTTPBB: PostData confirmed]; [Validated value of request: [NSString stringWithFormat: @ "% i", postDataConfirmed.length] forHTTPHeaderField: @ "content-length"]; NSURLResponse * response confirmed; NSError * Error Confirmed = Zero; NSDTA * Received Data Confirmation * [NSRR Connection Sending Synchronous: Request: Confirmation & amp; Reacted error: & amp; Error; Confirmed;); If (Error confirmed) {If (Received Confirmation KindOfClass: [NSHTTPURLResponse class]]) {NSHTTPURLResponse * httpResponseConfirmed = (NSHTTPURLResponse *) Feedback confirmed; Return; } Return; } NSString * responseStringConfirmed = [[NSString alloc] initWithData: Received Data Confirmation Encoding: NSUTF8StringEncoding]; If ([responseStringConfirmedEqualToString: @ "true"]) {return; } NSDictionary * json object has been confirmed [[responseStringConfirmed objectFromJSONString]; NSDictionary * jsonDictionary = [NSJSerification JSONObjectWithData: Received Data Confirmed Option: 0 Error: Zero]; NSArray * Confirmation = [jsonDictionary ObjectForreq: @ "confirmation_table"]; If ([Pertiary count]> 0) {[confirmedimimer invalid]; NSString * Confirmation message = @ ""; (Confirmation message = [Confirmation message stringBapping string: [NSString stringWithFormat: @ "confirm_id:% @ \ n", [NSNumber NumberAttah: [[Confirmation ObjectForcae: @ "Confirmation_ID" ] intValue]]]]]; Confirmation Message = [Confirmation StringBapping string: [NSString stringWithFormat: @ "order_id:% @ \ n", [with NSNumber numbers: [[Confirmation objectForace: @ "Order_ID"] ]Invival »]]] ;; Confirmation message = [Confirmation string stringBapping string: [NSString stringWithFormat: @ "Notice:% @", [Confirmed Objectwork: @ "Information"]]]; } UIAlertView * confirmedAlert = [[UIAlertView alloc] initWithTitle: @ "Confirmation" message: Confirmation message Representative: Cancel zeroTenTitle: @ "OK" other buttontitles: zero]; [Confirmation show]; [ConfirmationAlert Release]; }}

You do not check local notification server on this slightly backwards Instead, you apply background fetch and then post local information if the background fetch detects relevant data. There is a good tutorial for bringing the background.

Note that every 10 seconds will not be executed for the background

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -