After reading APNS documentation, I have implemented apns into my app. Everything works fine, but I have a question.
I don't know if it is possible, but I would like to do a task when my app is in background and I receive a apns notification.
This is my dictionary inside the notification:
aps =
{
alert = "message";
sound = "default";
};
If my app is in foreground, I execute this code:
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{
[HTTPConnection sendGetToUrl:[NSURL URLWithString:stringUrl]];
NSLog(@"Received notification: %@", userInfo);
}
But apns does not execute "didReceiveRemoteNotification" when the app is in background, so I would like to execute the method:
[HTTPConnection sendGetToUrl:[NSURL URLWithString:stringUrl]];
if I receive an apns notification in background.
Is there any way to do it?
Thanks so much!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…