1

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

笔记:

但我使用相同的应用程序密钥和应用程序主密钥进行开发和生产。所以它不适用于推送通知。如果我为分发创建单独的密钥并且必须将这些密钥用于我的分发构建。这样就可以解决问题了。在城市飞艇中创建应用程序密钥时,我会得到三个密钥,例如应用程序密钥、应用程序密钥和应用程序主密钥。我在我的应用程序中使用了应用程序密钥和主密钥。这个对吗?所以请指导我。

谢谢

问候,
普格尔

4

1 回答 1

3

你需要有:

  1. 在 Apple 的 iOS 配置门户中
    • 应用 ID
      • 生成开发推送 SSL 证书
      • 生成生产推送 SSL 证书
  2. 在 Urban Airship Application 编辑器中
    • 创建开发应用程序
      • 在 Apple 推送证书条目中使用 Apps Development Push SSL Certificate
      • 复制应用程序密钥(开发)
      • 复制应用程序机密(开发)
    • 为生产创建应用程序
      • 在 Apple 推送证书条目中使用 Apps Production Push 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)];
    

    }

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

于 2012-06-20T07:03:38.080 回答