OneSignal stores really good documentation.
For android, you can get user IDs using a method idsAvailable
that returns the user ID and registration ID.
userID aka playerID - UUID OneSignal. ( )
registrationID - Google ( ).
iOS , 2.5.0+ SDK iOS getPermissionSubscriptionState addSubscriptionObserver.
OSPermissionSubscriptionState Swift :
let status: OSPermissionSubscriptionState = OneSignal.getPermissionSubscriptionState()
let hasPrompted = status.permissionStatus.hasPrompted
print("hasPrompted = \(hasPrompted)")
let userStatus = status.permissionStatus.status
print("userStatus = \(userStatus)")
let isSubscribed = status.subscriptionStatus.subscribed
print("isSubscribed = \(isSubscribed)")
let userSubscriptionSetting = status.subscriptionStatus.userSubscriptionSetting
print("userSubscriptionSetting = \(userSubscriptionSetting)")
let userID = status.subscriptionStatus.userId
print("userID = \(userID)")
let pushToken = status.subscriptionStatus.pushToken
print("pushToken = \(pushToken)")
Objective-C:
OSPermissionSubscriptionState* status = [OneSignal getPermissionSubscriptionState];
status.permissionStatus.hasPrompted
status.permissionStatus.status
status.subscriptionStatus.subscribed
status.subscriptionStatus.userSubscriptionSetting
status.subscriptionStatus.userId
status.subscriptionStatus.pushToken
, :
let status: OSPermissionSubscriptionState = OneSignal.getPermissionSubscriptionState()
let userID = status.subscriptionStatus.userId
print("userID = \(userID)")
let pushToken = status.subscriptionStatus.pushToken
print("pushToken = \(pushToken)")
if pushToken != nil {
if let playerID = userID {
// do something
}
}