繁体   English   中英

iOS 中的 Urban Airship SDK 集成和推送通知

[英]Urban Airship SDK Integration in iOS & push notification

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

我们尝试使用 ad hoc 配置文件检查推送通知,我们在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];
}

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

告诉我我该怎么做。

因此,首先看起来您缺少一些应用程序委托方法

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM