【问题标题】:Push Not Coming in Production推送未投入生产
【发布时间】: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


【解决方案1】:

这些问题是由于当前的配置文件不包含 APNS 信息,因为配置文件是在创建 APNS 证书之前创建的。

因此,为了解决这个问题,创建一个新的 Provisioning Profile 并在 Xcode 中选择 Provisioning Profile 将清除错误。

另外,当您添加推送时,我相信您也更新了钥匙串中的证书。

【讨论】:

    猜你喜欢
    • 2013-04-24
    • 1970-01-01
    • 1970-01-01
    • 2021-03-08
    • 2011-06-27
    • 2014-10-12
    • 1970-01-01
    • 1970-01-01
    • 2014-11-05
    相关资源
    最近更新 更多