是否可以处理在后台收到的苹果推送通知?
答
我想你正在寻找didReceiveRemoteNotification
,这是在推送通知到达时被调用的方法。
你需要看看UIApplication Delegate Protocol Reference!远程通知还有其他一些方法。
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if (application.applicationState == UIApplicationStateActive)
// app was already in the foreground
else
// app was just brought from background to foreground
...
}
也期待在http://www.iphonedeveloperdiary.com/2010/06/receiving-apple-push-notifications-when-app-is-running/ – Legolas
此通知iPhone将收到只有当应用程序在前台模式。如果在后台模式下应用,它将只显示带有消息的警报,但不会引发此回调。 – Oksana