本文介绍了Apple 推送通知服务在 iPhone 中使用 Urban Airship 的生产构建中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have used Apple Push Notification in my apps and it works fine in Adhoc Distribution. I have submitted my apps into the AppStore, But push notification is not working for my apps and received message like "Apple rejected your device tokens". I have used separate .p12 files for development and production builds and uploaded in the Urban Airship.

注意:

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

But i have used the same application key and application master key for development and production. So that it didn't works for the push notification. If i create a separate keys for distribution and have to use those keys for my distribution builds. So that it will solve the problem. When a creating a application keys in urban airship, then i get the three keys like Application Key, Application Secret and Application Master secret. I have used the application key and Master key in my apps. Is this correct? So please guide me.

谢谢

问候,
普加尔

推荐答案

您需要具备:

  1. 在 Apple 的 iOS 配置门户中
    • 应用 ID
      • 生成开发推送 SSL 证书
      • 生成生产推送 SSL 证书
  • 创建用于开发的应用程序
    • 在 Apple 推送证书条目中使用应用开发推送 SSL 证书
    • 复制应用程序密钥(开发)
    • 复制应用程序机密(开发)
    • 在 Apple 推送证书条目中使用 Apps Production Push SSL 证书
    • 复制应用程序密钥(生产)
    • 复制应用程序机密(生产)

    我使用以下代码在编译时基于宏设置 Urban Airship Keys:

    I use the following code to set the Urban Airship Keys at compile time based on macros:

    - (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!).

    One of the best things about this set up is that I can send my beta testers push messages that my production users can not see (i.e.: New beta on TestFlight!).

    这篇关于Apple 推送通知服务在 iPhone 中使用 Urban Airship 的生产构建中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 05:07