【发布时间】:2015-10-21 06:21:38
【问题描述】:
我没有进入生产模式。虽然它在开发人员模式下工作正常。这是我的代码,我在 iOS 中比较新,我是第一次实现 APN。请帮忙。我被困在很多时间。
if (iOSversion >=8) {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication]registerForRemoteNotifications];
}
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}
[[UIApplication sharedApplication] registerForRemoteNotifications];
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)tokenss
{
NSUInteger rntypes;
NSString *device=[[UIDevice currentDevice]systemVersion];
int ar=[device intValue];
if (ar>=8) {
rntypes = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];
}
NSString *deviceToken =[self stringWithDeviceToken:tokenss];
NSLog(@"Device token: %@", deviceToken);
callBackToken =deviceToken;
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
{
NSString *errorString = [NSString stringWithFormat: @"Error: %@", err];
NSLog(@"%@",errorString);
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
//register to receive notifications
[application registerForRemoteNotifications];
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
{
//handle the actions
if ([identifier isEqualToString:@"declineAction"]){
}
else if ([identifier isEqualToString:@"answerAction"]){
}
}
【问题讨论】:
-
检查 iOS 中的生产模式证书和服务器端的生产模式..(检查是否有可能是沙盒模式)
标签: objective-c iphone push-notification