-1

i am doing one application.In that application i am using APNS.My server is going to send the notifications to APNS.And APNS forward that notifications to devices.Total process is ok.It's working correctly.But i want to

  -get the conformation from APNS whether device received the notification or not to my server.

  -And how to know notification received by device when we open the application by touching the application icon not swipe the notification. 
Gsr Ios
  • 3
  • 4

2 Answers2

1

The APNS service is best effort and not guaranteed delivery. There isn't really any way to get an understanding about what notifications were delivered.

However, you can find out about failed notifications - but that is more to do with the app being uninstalled or push notifications turned off for the device itself: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html

That might be the closest you can get via APNS.

Otherwise I'd recommend having some kind of phone-home call made by the app on start up to query the server about information it should have received so that you can get your state correct.

Andy Raines
  • 297
  • 1
  • 3
  • 9
0

For the first one, APNS doesn't provide any callback whether the device received the notification or not. If you want you can implement something in your device to tell your server whenever it receives a notification.

For the second, you can have some help from this code.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    if ( application.applicationState == UIApplicationStateInactive || application.applicationState == UIApplicationStateBackground  )
    {
         //opened from a push notification when the app was on background
    }
}

More help from this answer.

This is called when app was in background. If you want to get information for the app which started by push notification, you need to use the following code, in your didFinishLaunchingWithOptions

 UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (notification) {
    NSLog(@"app recieved notification from remote%@",notification);
    [self application:application didReceiveRemoteNotification:(NSDictionary*)notification];
}else{
    NSLog(@"app did not recieve notification");
}
Community
  • 1
  • 1
Shamas S
  • 7,507
  • 10
  • 46
  • 58
  • didreceiveRemoteNotification method will fire whenever we swipe the notification right? – Gsr Ios Apr 06 '15 at 12:08
  • Yes what u r saying is correct.But i want to open my application without swipe the notification.I can clikc on app icon and open the app.SO in that time i want to know about notification. – Gsr Ios Apr 06 '15 at 12:17