Apple Push Notification Service在iPhone中使用Urban Airship的生产构建中不起作用吗?

时间:2011-04-20 15:26:44

标签: iphone distribution apple-push-notifications urbanairship.com

我在我的应用中使用了Apple推送通知,它在Adhoc Distribution中运行良好。我已将我的应用程序提交到AppStore,但推送通知对我的应用程序无效,并收到“Apple拒绝您的设备令牌”等消息。我使用单独的.p12文件进行开发和生产构建,并上传到Urban Airship。

注意:

但我使用相同的应用程序密钥和应用程序主密钥进行开发和生产。因此它不适用于推送通知。如果我创建一个单独的密钥用于分发,并且必须将这些密钥用于我的分发版本。这样它就能解决问题。当在城市飞艇中创建应用程序键时,我会得到应用程序密钥,应用程序密钥和应用程序主密钥等三个密钥。我在我的应用程序中使用了应用程序密钥和主密钥。它是否正确?所以请指导我。

由于

的问候,
Pugal

1 个答案:

答案 0 :(得分:3)

你需要:

  1. 在Apple的iOS配置门户中
    • App ID
      • 生成开发推送SSL证书
      • 生成生产推送SSL证书
  2. 在Urban Airship Application编辑器中
    • 创建开发应用程序
      • 使用Apple推送证书条目中的应用程序开发推送SSL证书
      • 复制应用程序密钥(开发)
      • 复制应用程序密钥(开发)
    • 创建生产应用程序
      • 使用Apple推送证书条目中的应用程序生产推送SSL证书
      • 复制应用程序密钥(生产)
      • 复制应用程序密钥(生产)
  3. 设置Xcode的代码签名以使用证书
  4. 我使用以下代码在编译时根据宏设置Urban Airship Keys:

    - (void)urbanAirshipTakeoffWithLaunchOptions:(NSDictionary *)launchOptions {
    
    // Init Airship launch options
    NSMutableDictionary *takeOffOptions = [[NSMutableDictionary alloc] init];
    [takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];
    
    // Build the Urban Airship TakeOffOptions
    // Create Airship singleton that's used to talk to Urban Airship servers.
    NSMutableDictionary *airshipConfigOptions = [[NSMutableDictionary alloc] init];
    
    //Set up the Push keys
    NSLog(@"Appdelegate_Pad:didFinishLaunchingWithOptions - TARGET_1");
    [airshipConfigOptions setValue:@"xxx" forKey:@"DEVELOPMENT_APP_KEY"];
    [airshipConfigOptions setValue:@"xxx" forKey:@"DEVELOPMENT_APP_SECRET"];
    [airshipConfigOptions setValue:@"xxx" forKey:@"PRODUCTION_APP_KEY"];
    [airshipConfigOptions setValue:@"xxx" forKey:@"PRODUCTION_APP_SECRET"];
    
    // If CONFIGURATION_Debug is defined, then use the development servers, else use the production servers
    #ifdef CONFIGURATION_Debug
    [airshipConfigOptions setValue:@"NO" forKey:@"APP_STORE_OR_AD_HOC_BUILD"];
    NSLog(@"Using Development Servers at Urban Airship");
    #else
    [airshipConfigOptions setValue:@"YES" forKey:@"APP_STORE_OR_AD_HOC_BUILD"];
    NSLog(@"Using Production Servers at Urban Airship");
    #endif
    
    // Set and start Urban Airship
    [takeOffOptions setValue:airshipConfigOptions forKey:UAirshipTakeOffOptionsAirshipConfigKey];
    [UAirship takeOff:takeOffOptions];
    
    // Register for push notifications
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                                                           UIRemoteNotificationTypeSound |
                                                                           UIRemoteNotificationTypeAlert)];
    

    }

  5. 关于这个设置的最好的事情之一是我可以发送我的生产用户看不到的beta测试者推送消息(即:TestFlight上的新测试版!)。