Mobile SDK Mapping
Maps method names from our older Player Model SDKs (v3 & v4) to User Model (v5+)
You're Viewing User Model Documentation
OneSignal is in the process of migrating from a device-centric model (player ID) to a new user-centric data model (OneSignal ID). To learn more, check out the User Model Migration Guide.
Please refer to Version 9 of our documentation for device-centric information.
The structure of this document is similar to the one in the original Player Model Client SDK Reference doc. The headers indicate the method()
and property
names from the Player Model, and the code snippet shows the differences between the two models. All snippets are presented in the Swift programming language and may not represent complete working code. Please refer to the docs linked for each method/property to see examples in other languages and to learn more about it.
Initializing OneSignal
initWithLaunchOptions()
initWithLaunchOptions()
Player Model doc
OneSignal.initWithLaunchOptions(launchOptions)
OneSignal.setAppId("ONESIGNAL_APP_ID")
User Model doc
OneSignal.initialize("YOUR_ONESIGNAL_APP_ID", withLaunchOptions: launchOptions)
Debugging
setLogLevel()
setLogLevel()
Player Model doc
OneSignal.setLogLevel(.LL_VERBOSE, visualLevel: .LL_NONE)
User Model doc
OneSignal.Debug.setLogLevel(.LL_VERBOSE)
External User IDs
setExternalId()
setExternalId()
Player Model doc
OneSignal.setExternalId("EXTERNAL_USER_ID")
User Model doc
OneSignal.login("EXTERNAL_USER_ID")
removeExternalUserId()
removeExternalUserId()
Player Model doc
OneSignal.removeExternalUserId({ results in ... })
User Model doc
OneSignal.logout()
Tags
sendTag()
sendTag()
Player Model doc
OneSignal.sendTag("key", value: "value")
User Model doc
OneSignal.User.addTag(key: "key", value: "value")
sendTags()
sendTags()
Player Model doc
OneSignal.sendTags(["key1": "value1", "key2": "value2"])
User Model doc
OneSignal.User.addTags(["key1": "value1", "key2": "value2"])
getTags()
getTags()
Player Model doc
OneSignal.getTags({ tags in ..., onFailure: { error in ... })
User Model doc
let tags = OneSignal.User.getTags()
deleteTag()
deleteTag()
Player Model doc
OneSignal.deleteTag("key")
User Model doc
OneSignal.User.removeTag("key")
deleteTags()
deleteTags()
Player Model doc
OneSignal.deleteTags(["key1", "key2"])
User Model doc
OneSignal.User.removeTags(["key1", "key2"])
User Data
notificationPermissionStatus
notificationPermissionStatus
Player Model doc
OneSignal.getDeviceState().notificationPermissionStatus
User Model doc
OneSignal.Notifications.permissionNative
userId
userId
Player Model doc
OneSignal.getDeviceState().userId
User Model doc
OneSignal.User.pushSubscription.id
areNotificationsEnabled
areNotificationsEnabled
Equivalent to hasNotificationPermission
.
hasNotificationPermission()
hasNotificationPermission()
Player Model doc
OneSignal.getDeviceState().areNotificationsEnabled()
User Model doc
OneSignal.Notifications.permission
pushToken
pushToken
Player Model doc
OneSignal.getDeviceState().pushToken
User Model doc
OneSignal.User.pushSubscription.token
hasNotificationPermission
hasNotificationPermission
Player Model doc
OneSignal.getDeviceState().hasNotificationPermission
User Model doc
OneSignal.User.pushSubscription.optedIn
isSubscribed
[dropped]
isSubscribed
[dropped]Player Model doc
OneSignal.getDeviceState().isSubscribed
User Model
NA
isPushDisabled
[dropped]
isPushDisabled
[dropped]Player Model doc
OneSignal.getDeviceState().isPushDisabled
User Model
NA
setLanguage()
setLanguage()
Player Model doc
OneSignal.setLanguage("es")
User Model doc
OneSignal.User.setLanguage("en")
Privacy
setRequiresUserPrivacyConsent()
setRequiresUserPrivacyConsent()
Player Model doc
OneSignal.setRequiresUserPrivacyConsent(true)
User Model doc
OneSignal.setConsentRequired(true)
consentGranted()
consentGranted()
Player Model doc
OneSignal.consentGranted(true)
User Model doc
OneSignal.setConsentGiven(true)
Location
setLocationShared()
setLocationShared()
Player Model doc
OneSignal.setLocationShared(false)
User Model
OneSignal.Location.isShared = false
isLocationShared()
isLocationShared()
Player Model doc
OneSignal.isLocationShared()
User Model
OneSignal.Location.isShared
promptLocation()
promptLocation()
Player Model doc
OneSignal.promptLocation()
User Model doc
OneSignal.Location.requestPermission()
addSubscriptionObserver()
addSubscriptionObserver()
User Model doc
OneSignal.addSubscriptionObserver(subscriptionObserver)
User Model doc
OneSignal.User.pushSubscription.addObserver(pushSubscriptionObserver)
removeSubscriptionObserver()
removeSubscriptionObserver()
User Model doc
Onesignal.removeSubscriptionObserver(subscriptionObserver)
User Model doc
OneSignal.User.pushSubscription.removeObserver(pushSubscriptionObserver)
Push Notifications
promptForPushNotifications()
promptForPushNotifications()
Player Model doc
OneSignal.promptForPushNotifications()
User Model doc
OneSignal.Notifications.requestPermission()
postNotification()
[dropped]
postNotification()
[dropped]Player Model doc
OneSignal.postNotification()
User Model
NA
clearOneSignalNotifications()
clearOneSignalNotifications()
Player Model doc
OneSignal.clearOneSignalNotifications()
User Model doc
OneSignal.Notifications.clearAll()
disablePush()
disablePush()
Player Model doc
OneSignal.disablePush(true)
User Model doc
OneSignal.User.pushSubscription.optOut()
unsubscribeWhenNotificationsAreDisabled()
[dropped]
unsubscribeWhenNotificationsAreDisabled()
[dropped]Player Model doc
OneSignal.unsubscribeWhenNotificationsAreDisabled(false)
User Model
NA
setLaunchURLsInApp()
[dropped]
setLaunchURLsInApp()
[dropped]Player Model doc
OneSignal.setLaunchURLsInApp(true)
User Model
NA
registerForProvisionalAuthorization()
registerForProvisionalAuthorization()
Player Model doc
OneSignal.registerForProvisionalAuthorization({userResponse in ...})
User Model
OneSignal.Notifications.registerForProvisionalAuthorization({ userReponse in ... })
setNotificationWillShowInForegroundHandler()
setNotificationWillShowInForegroundHandler()
Player Model doc
OneSignal.setNotificationWillShowInForegroundHandler(foregroundHandler)
User Model doc
OneSignal.Notifications.addForegroundLifecycleListener(notificationLifecyleHandler)
setNotificationOpenedHandler()
setNotificationOpenedHandler()
Player Model doc
OneSignal.setNotificationOpenedHandler(notificationOpenHandler)
User Model doc
OneSignal.Notifications.addClickListener(notificationClickListener)
addPermissionObserver()
addPermissionObserver()
Player Model doc
OneSignal.addPermissionObserver(self as OSPermissionObserver)
User Model doc
OneSignal.Notifications.addPermissionObserver(notificationPermissionObserver)
removePermissionObserver()
removePermissionObserver()
Player Model doc
OneSignal.removePermissionObserver()
User Model doc
OneSignal.Notifications.removePermissionObserver(notificationPermissionObserver)
Live Activities
enterLiveActivity()
enterLiveActivity()
Player Model doc
OneSignal.enterLiveActivity("my_activity_id", withToken: myToken)
User Model doc
OneSignal.LiveActivities.enter("my_activity_id", withToken: "TOKEN")
exit()
exit()
Player Model doc
OneSignal.exitLiveActivity("my_activity_id")
User Model doc
OneSignal.LiveActivities.exit("my_activity_id")
In-App Messages
addTrigger()
addTrigger()
Player Model doc
OneSignal.addTrigger("prompt_ios", withValue: "true");
User Model doc
OneSignal.InAppMessages.addTrigger("KEY", withValue: "VALUE")
addTriggers()
addTriggers()
Player Model doc
OneSignal.addTriggers(["trigger_key_1": "1", "trigger_key_2": "some_other_value"])
User Model doc
OneSignal.InAppMessages.addTriggers(["trigger_key_1": "1", "trigger_key_2": "some_other_value"])
removeTriggerForKey()
removeTriggerForKey()
Player Model doc
OneSignal.removeTriggerForKey("trigger_key_1");
User Model doc
OneSignal.InAppMessages.removeTrigger("trigger_key_1")
removeTriggerForKeys()
removeTriggerForKeys()
Player Model doc
OneSignal.removeTriggerForKeys(["trigger_key_1", "trigger_key_2"])
User Model doc
OneSignal.InAppMessages.removeTriggers(["trigger_key_1", "trigger_key_2"])
getTriggerValueForKey()
[dropped]
getTriggerValueForKey()
[dropped]Player Model doc
OneSignal.getTriggerValueForKey("trigger_key");
User Model
NA
inAppMessagesArePaused
inAppMessagesArePaused
Player Model doc
OneSignal.inAppMessagesArePaused = true
User Model doc
OneSignal.InAppMessages.paused = true
setInAppMessageLifecycleHandler()
setInAppMessageLifecycleHandler()
Player Model doc
OneSignal.setInAppMessageLifecycleHandler(handler)
User Model doc
OneSignal.InAppMessages.addLifecycleListener(listener)
setInAppMessageClickHandler()
setInAppMessageClickHandler()
Player Model doc
OneSignal.setInAppMessageClickHandler(clickHandler)
User Model doc
OneSignal.InAppMessages.addClickListener(clickListener)
Email
setEmail()
setEmail()
Player Model doc
OneSignal.setEmail("[email protected]")
User Model doc
OneSignal.User.addEmail("[email protected]")
logoutEmail()
logoutEmail()
Player Model doc
OneSignal.logoutEmail()
User Model doc
OneSignal.User.removeEmail("[email protected]")
SMS
setSMSNumber()
setSMSNumber()
Player Model doc
OneSignal.setSMSNumber("+11234567890")
User Model doc
OneSignal.User.addSms("+11234567890")
logoutSMSNumber()
logoutSMSNumber()
Player Model doc
OneSignal.logoutSMSNumber()
User Model doc
OneSignal.User.removeSms("+11234567890")
addSMSSubscriptionObserver()
[dropped]
addSMSSubscriptionObserver()
[dropped]Player Model doc
OneSignal.add(subscriptionObserver)
User Model
NA
getSMSId()
[dropped]
getSMSId()
[dropped]Player Model doc
OneSignal.Default.SMSSubscriptionState.smsUserId
User Model
NA
Outcomes
sendOutcome()
sendOutcome()
Player Model doc
OneSignal.sendOutcome("Purchase")
User Model doc
OneSignal.Session.addOutcome("Purchase")`
sendOutcomeWithValue()
sendOutcomeWithValue()
Player Model doc
OneSignal.sendOutcomeWithValue(withValue: "Purchase", value: 18.76)
User Model doc
OneSignal.Session.addOutcome("Purchase", 18.76)
sendUniqueOutcome()
sendUniqueOutcome()
Player Model doc
OneSignal.sendUniqueOutcome("Swipe");
User Model doc
OneSignal.Session.addUniqueOutcome("Swipe")
Updated 2 months ago