usually you do not update the apns token on the server in the e-mail itself. you save it and update it later when you define the user.
You can do it as follows:
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken { const unsigned *tokenBytes = [deviceToken bytes]; NSString *hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x", ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]), ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]), ntohl(tokenBytes[6]), ntohl(tokenBytes[7])]; [[MyModel sharedModel] setApnsToken:hexToken]; }
with this, you saved the apns token in the Model object (MyModel). And later, when you defined your user (by login / registration or any other method)
you can call this method
[self sendProvidedDeviceToken: [[MyModel sharedModel] apnsToken] forUserWithId: userId];
Thus, you have connected the device token with the user. Hope this helps!
source share