Apple推送通知确认

时间:2015-04-06 11:57:08

标签: ios apple-push-notifications

我正在做一个应用程序。在那个应用程序中,我正在使用APNS.My服务器将向APNS发送通知。并且APNS将通知发送到设备。总过程正常。它正常工作。但我想要< / p>

  -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. 

2 个答案:

答案 0 :(得分:1)

APNS服务是尽力而为,不保证交付。没有任何方法可以了解已发送的通知。

但是,您可以找到有关失败通知的信息 - 但这更多地与卸载的应用或关闭设备本身的推送通知有关: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html

这可能是您通过APNS获得的最接近的。

否则我建议在启动时通过应用程序进行某种电话回拨,以便向服务器查询应该收到的信息,以便您的状态正确无误。

答案 1 :(得分:0)

对于第一个,APNS不提供任何回调,无论设备是否收到通知。 如果您愿意,您可以在设备中实现某些功能,以便在收到通知时告知您的服务器。

对于第二个,您可以从此代码中获得一些帮助。

- (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
    }
}

this answer.

提供更多帮助

当app在后台时调用此方法。如果您想获取通过推送通知启动的应用程序的信息,您需要在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");
}