我正在开发iOS 8中的iOS应用程序。它有一个名为消息发送的模块。该模块是在Apple推送通知的帮助下开发的。我的问题是有时候我们没有将Push消息发送到iOS设备。服务器成功将消息发送到APNS。这是APNS的可靠性问题吗?
我正在使用以下步骤:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
{
UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
return YES;
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[application registerForRemoteNotifications];
}
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
}
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
}
答案 0 :(得分:0)
通过answer
答案 1 :(得分:0)
Samraan没有错,Apple不保证交付,但是根据我的经验它是非常可靠的。我在您发布的代码中注意到的是didReceiveRemoteNotification
有一个空的实现。当您的应用处于活动状态并且收到推送通知时,不会显示系统横幅或提醒。相反,通知会传递到didReceiveRemoteNotification
回调,以便您的应用直接处理。如果您对此功能有一个空的定义,并且您向该设备发送通知,则可能看起来通知从未到达,而是只是隐藏了。
您可以尝试在此回调中添加UIAlertView弹出窗口,以确定您的情况是否正在发生这种情况。