Piscean
Piscean

Reputation: 3079

Push Notifications warning?

I am working with push notifications in my app. but I am getting this warning: Incompatible Objective-C types assigning 'struct NSString *', expected 'struct NSData *'

the code where its getting warning is:

  - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Here you send the deviceToken to your server.. 
deviceToken = [[[[deviceToken description]
                 stringByReplacingOccurrencesOfString: @"<" withString: @""]
                stringByReplacingOccurrencesOfString: @">" withString: @""]
               stringByReplacingOccurrencesOfString: @" " withString: @""];

NSLog(@"Device Token: %@",deviceToken);
}

Can anybody tell me why did I got that warning.

Thanks

Upvotes: 0

Views: 236

Answers (1)

Robert Redmond
Robert Redmond

Reputation: 1522

Why don't you create a separate NSString called deviceTokenStr as deviceToken itself is an NSData object and it is causing the error

    NSString *deviceTokenStr = [[[[deviceToken description] stringByReplacingOccurrencesOfString:      @"<" withString: @""] stringByReplacingOccurrencesOfString: @">" withString: @""] stringByReplacingOccurrencesOfString: @" " withString: @""];

    NSLog(@"Device Token: %@",deviceTokenStr);

Upvotes: 1

Related Questions