【发布时间】:2015-02-28 00:22:46
【问题描述】:
在涉及推送通知的应用程序中,我可以正常接收设备令牌,但我客户的设备没有收到设备令牌(因此导致无法接收推送通知)。我正在使用 Parse 进行推送通知。这就是我的AppDelegate:
-(void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken {
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:newDeviceToken];
PFACL *objectACL = [[PFACL alloc] init];
[objectACL setPublicReadAccess:YES];
[objectACL setPublicWriteAccess:YES];
[currentInstallation saveInBackground];
}
-(void) application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSString *errorString = [NSString stringWithFormat:@"%@", error];
UIAlertView *errorAlertView = [[UIAlertView alloc] initWithTitle:@"Error" message:errorString delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[errorAlertView show];
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
[application registerForRemoteNotifications];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[Parse setApplicationId:PARSE_APPLICATION_ID
clientKey:PARSE_CUSTOMER_KEY];
[PFFacebookUtils initializeFacebook];
[self.window makeKeyAndVisible];
// create the Login controller instance:
[application registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
}
客户端没有收到任何表示向 APN 注册失败的 UIAlert,这意味着没有调用 didFailToRegisterForRemoteNotificationsWithError。我已尝试根据 Apple 技术说明 TN2265 的指南从我的解析服务器中删除所有安装,删除应用程序并重新安装。该应用程序不会在首次启动时提示客户端授权推送通知并且也不会出现在通知中心(这令人困惑,因为didRegisterUserNotificationSettings: 也在那里)。但这一切在我的 iPad、iPhone 5S、iPod 5、iPhone 4s 上运行良好。任何想法可能导致此设备在应用程序中设备变量行为?!这是 sc 客户端发送给我的。notificationCenterScreenShot
【问题讨论】:
-
你能告诉我你是如何注册推送通知的吗?
-
我也添加了 didFinish 方法
标签: ios iphone apple-push-notifications