Another way to get push device token ios?
Solution 1:
You can get the push token for OneSignal SDK like this:
OneSignal.promptForPushNotifications(userResponse: { accepted in
print("User accepted notifications: \(accepted)")
if let deviceState = OneSignal.getDeviceState() {
let userId = deviceState.userId
let pushToken = deviceState.pushToken
let subscribed = deviceState.isSubscribed
print("pushToken ====> \(pushToken)") //Here you can get the token
}
})
Keep coding........... :)
Solution 2:
OneSignal
API states IdsAvailable
is the method you would use:
[OneSignal IdsAvailable:^(NSString* userId, NSString* pushToken) {
NSLog(@"UserId:%@", userId);
if (pushToken != nil)
NSLog(@"pushToken:%@", pushToken);
}];
Is the method to get the token; mentioned here.