【问题标题】:Urban Airship SDK Integration in iOS & push notificationiOS 中的 Urban Airship SDK 集成和推送通知
【发布时间】:2015-11-04 17:11:02
【问题描述】:

我们已经使用这些guidelines 集成了 Urban SDK。

我们尝试使用临时配置文件检查推送通知,其中我们在 AirshipConfig.plist

中设置了以下值
  • inProduction=YES
  • productionAppKey=OUR PRODUCTION KEY
  • productionAppSecret= OUR PRODUCTION SECRET

请检查我们在项目的 AppDelegate 文件中实现的以下代码。


-(void) applicationDidFinishLaunching: (UIApplication *)application
{
.
.
.
.
 UAConfig *config = [UAConfig defaultConfig];
 config.automaticSetupEnabled=NO;
 [UAirship takeOff:config];

 if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
    {
        NSLog(@"------------REGISTER DEVICE------------: >= 8");
        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    }
    else
    {
        NSLog(@"------------REGISTER DEVICE------------: <8 ");
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
         (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
    }
.
.
.
.

}

#pragma mark Remote Notification methods


-(void) application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken // Device Registration
{
    [[UAirship push] appRegisteredForRemoteNotificationsWithDeviceToken:devToken];

}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
    [[UAirship push] appRegisteredUserNotificationSettings];

}
-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
   NSLog(@"%@", error);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    NSLog(@"NOTIFICATION------------ didReceiveRemoteNotification ------------ %@", userInfo);
    [[UAirship push] appReceivedRemoteNotification:userInfo applicationState:application.applicationState];
}

当我们尝试向注册的设备令牌发送通知时,服务器将该设备令牌显示为 INACTIVE 设备令牌。

告诉我我该怎么做。

【问题讨论】:

  • 您实际上是在生产中还是在通过 Xcode 在您的设备上进行测试?如果不是,请将其设置为 false。
  • @QuentinHayot,我已经使用临时配置文件创建了构建并在真实设备中对其进行了测试。
  • 但它还在测试中,不是发布版本,所以你必须使用开发模式。
  • 实际上在AirshipConfig.plist中有5个键值。 inProduction,developmentAppKey,developmentAppSecret,productionAppKey,productionAppSecret 所以如果我使用临时配置文件,我应该使用 inProduction = true ,productionAppKey= key,productionAppSecret=secret。不是吗?
  • 你在为应用商店制作这个应用吗?

标签: ios objective-c push-notification urbanairship.com devicetoken


【解决方案1】:

所以,首先看起来您缺少一些应用程序delegate methods

Urban Airship 处理 APNS 注册。删除您的手动注册调用,因为 UA 只会覆盖它们,而是使用 [UAirship push].userPushNotificationsEnabled = YES; 启用通知。它应该提示用户接受通知,然后应该选择加入 Urban Airship 频道。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多