简体   繁体   中英

Urban Airship SDK Integration in iOS & push notification

We have integrated Urban SDK using these guidelines .

We have tried to check the push notification using ad hoc profile where we have set below values in AirshipConfig.plist

  • inProduction=YES
  • productionAppKey=OUR PRODUCTION KEY
  • productionAppSecret= OUR PRODUCTION SECRET

Please check the below code which we have implemented in the AppDelegate file of project.


-(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];
}

When we are trying to send the notification to the registered device token, the server shows that device token as INACTIVE Device token.

Please show me what should I do for this.

So, first it looks like you are missing a few app delegate methods .

Urban Airship handles APNS registration. Remove your manual registration calls as UA will just override them, and instead, enable notifications with [UAirship push].userPushNotificationsEnabled = YES; . It should prompt the user to accept notifications, and then the Urban Airship channel should be opted in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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