0

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

Piscean
  • 3,069
  • 12
  • 47
  • 96

1 Answers1

1

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);
Robert Redmond
  • 1,522
  • 13
  • 16