Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Of course, you can do so.</p> <ul> <li><p>you add some custom field in your push notification payload, in my case, the 'msgId' can the field you need.</p> <pre><code>$body = array(); $body['device_tokens'] = str_replace(' ', '', $_REQUEST["Token"]); $body['msgId'] = $MP_ID; $body['aps'] = array('alert' =&gt; $alertShort); $payload = json_encode($body); </code></pre></li> <li><p>send the payload to APN server (sandbox server/official server, depends on your situation)</p></li> <li><p>add the code to receive APN </p> <pre><code> -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { NSLog(@"I got notification"); [NSThread detachNewThreadSelector:@selector(handleRemoteNotification:) toTarget:self withObject:userInfo]; } - (void)handleRemoteNotification:(NSDictionary *)userInfo { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [UIApplication sharedApplication].applicationIconBadgeNumber++;// = [[[userInfo objectForKey:@"aps"] objectForKey:@"badge"] integerValue]; if ([userInfo objectForKey:@"msgId"]) { iRetrievingAPNMessage++; NSString *msgId = [[NSString alloc] initWithString:[userInfo objectForKey:@"msgId"]]; NSMutableString *theURL = [[NSMutableString alloc] init]; [theURL appendFormat:@"http://yourDATAFeedPROGRAM.php?msgID=%@",msgId]; MIPFileConnection *APNMsgConnection = [[MIPFileConnection alloc] initWithTargetURL:theURL useCache:NO]; APNMsgConnection.delegate = self; [APNMsgConnection start]; NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; do { } while ((iRetrievingAPNMessage &gt; 0) &amp;&amp; [runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]); NSLog(@"done"); } [pool release]; } - (void)updateDB:(NSDictionary *)msgDic { // do anything to update your sql db. // ATTENTION, the files located in bundle cannot be replaced. // so you need to duplicate your sql into cache/document path. // then you can update it successfully. } -(void)connectionDidFinishLoading:(NSURLFileConnection *)connection { CFPropertyListRef plist = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, (CFDataRef)connection.receiveData, kCFPropertyListImmutable, NULL); if (plist) { NSDictionary *tmpDic = (NSDictionary *)plist; [self performSelectorOnMainThread:@selector(updateDB:) withObject:[tmpDic copy] waitUntilDone:NO]; [tmpDic release]; } iRetrievingAPNMessage--; } </code></pre></li> </ul> <p>I used pseudo code in "updateDB", and fake URL, please replace it with your testing web URL. The above action works, I did it ok. But I cannot force the notification to show image when my app is in background.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload