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()

Player Model doc

OneSignal.initWithLaunchOptions(launchOptions)
OneSignal.setAppId("ONESIGNAL_APP_ID")

User Model doc

OneSignal.initialize("YOUR_ONESIGNAL_APP_ID", withLaunchOptions: launchOptions)

Debugging

setLogLevel()

Player Model doc

OneSignal.setLogLevel(.LL_VERBOSE, visualLevel: .LL_NONE)

User Model doc

OneSignal.Debug.setLogLevel(.LL_VERBOSE)

External User IDs

setExternalId()

Player Model doc

OneSignal.setExternalId("EXTERNAL_USER_ID")

User Model doc

OneSignal.login("EXTERNAL_USER_ID")

removeExternalUserId()

Player Model doc

OneSignal.removeExternalUserId({ results in ... })

User Model doc

OneSignal.logout()

Tags

sendTag()

Player Model doc

OneSignal.sendTag("key", value: "value")

User Model doc

OneSignal.User.addTag(key: "key", value: "value")

sendTags()

Player Model doc

OneSignal.sendTags(["key1": "value1", "key2": "value2"])

User Model doc

OneSignal.User.addTags(["key1": "value1", "key2": "value2"])

getTags()

Player Model doc

OneSignal.getTags({ tags in ..., onFailure: { error in ... })

User Model doc

let tags = OneSignal.User.getTags()

deleteTag()

Player Model doc

OneSignal.deleteTag("key")

User Model doc

OneSignal.User.removeTag("key")

deleteTags()

Player Model doc

OneSignal.deleteTags(["key1", "key2"])

User Model doc

OneSignal.User.removeTags(["key1", "key2"])

User Data

notificationPermissionStatus

Player Model doc

OneSignal.getDeviceState().notificationPermissionStatus

User Model doc

OneSignal.Notifications.permissionNative

userId

Player Model doc

OneSignal.getDeviceState().userId

User Model doc

OneSignal.User.pushSubscription.id

areNotificationsEnabled

Equivalent to hasNotificationPermission.

hasNotificationPermission()

Player Model doc

OneSignal.getDeviceState().areNotificationsEnabled()

User Model doc

OneSignal.Notifications.permission

pushToken

Player Model doc

OneSignal.getDeviceState().pushToken

User Model doc

OneSignal.User.pushSubscription.token

hasNotificationPermission

Player Model doc

OneSignal.getDeviceState().hasNotificationPermission 

User Model doc

OneSignal.User.pushSubscription.optedIn

isSubscribed [dropped]

Player Model doc

OneSignal.getDeviceState().isSubscribed

User Model
NA

isPushDisabled [dropped]

Player Model doc

OneSignal.getDeviceState().isPushDisabled

User Model
NA

setLanguage()

Player Model doc

OneSignal.setLanguage("es")

User Model doc

OneSignal.User.setLanguage("en")

Privacy

setRequiresUserPrivacyConsent()

Player Model doc

OneSignal.setRequiresUserPrivacyConsent(true)

User Model doc

OneSignal.setConsentRequired(true)

consentGranted()

Player Model doc

OneSignal.consentGranted(true)

User Model doc

OneSignal.setConsentGiven(true)

Location

setLocationShared()

Player Model doc

OneSignal.setLocationShared(false)

User Model

OneSignal.Location.isShared = false

isLocationShared()

Player Model doc

OneSignal.isLocationShared()

User Model

OneSignal.Location.isShared

promptLocation()

Player Model doc

OneSignal.promptLocation()

User Model doc

OneSignal.Location.requestPermission()

addSubscriptionObserver()

User Model doc

OneSignal.addSubscriptionObserver(subscriptionObserver)

User Model doc

 OneSignal.User.pushSubscription.addObserver(pushSubscriptionObserver)

removeSubscriptionObserver()

User Model doc

Onesignal.removeSubscriptionObserver(subscriptionObserver)

User Model doc

 OneSignal.User.pushSubscription.removeObserver(pushSubscriptionObserver)

Push Notifications

promptForPushNotifications()

Player Model doc

OneSignal.promptForPushNotifications()

User Model doc

OneSignal.Notifications.requestPermission()

postNotification() [dropped]

Player Model doc

OneSignal.postNotification()

User Model
NA

clearOneSignalNotifications()

Player Model doc

OneSignal.clearOneSignalNotifications()

User Model doc

OneSignal.Notifications.clearAll()

disablePush()

Player Model doc

OneSignal.disablePush(true)

User Model doc

OneSignal.User.pushSubscription.optOut()

unsubscribeWhenNotificationsAreDisabled() [dropped]

Player Model doc

OneSignal.unsubscribeWhenNotificationsAreDisabled(false)

User Model
NA

setLaunchURLsInApp() [dropped]

Player Model doc

OneSignal.setLaunchURLsInApp(true)

User Model
NA

registerForProvisionalAuthorization()

Player Model doc

OneSignal.registerForProvisionalAuthorization({userResponse in ...})

User Model

OneSignal.Notifications.registerForProvisionalAuthorization({ userReponse in ... })

setNotificationWillShowInForegroundHandler()

Player Model doc

OneSignal.setNotificationWillShowInForegroundHandler(foregroundHandler)

User Model doc

OneSignal.Notifications.addForegroundLifecycleListener(notificationLifecyleHandler)

setNotificationOpenedHandler()

Player Model doc

OneSignal.setNotificationOpenedHandler(notificationOpenHandler)

User Model doc

OneSignal.Notifications.addClickListener(notificationClickListener)

addPermissionObserver()

Player Model doc

OneSignal.addPermissionObserver(self as OSPermissionObserver)

User Model doc

OneSignal.Notifications.addPermissionObserver(notificationPermissionObserver)

removePermissionObserver()

Player Model doc

OneSignal.removePermissionObserver()

User Model doc

OneSignal.Notifications.removePermissionObserver(notificationPermissionObserver)

Live Activities

enterLiveActivity()

Player Model doc

OneSignal.enterLiveActivity("my_activity_id", withToken: myToken)

User Model doc

OneSignal.LiveActivities.enter("my_activity_id", withToken: "TOKEN")

exit()

Player Model doc

OneSignal.exitLiveActivity("my_activity_id")

User Model doc

OneSignal.LiveActivities.exit("my_activity_id")

In-App Messages

addTrigger()

Player Model doc

OneSignal.addTrigger("prompt_ios", withValue: "true");

User Model doc

OneSignal.InAppMessages.addTrigger("KEY", withValue: "VALUE")

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()

Player Model doc

OneSignal.removeTriggerForKey("trigger_key_1");

User Model doc

OneSignal.InAppMessages.removeTrigger("trigger_key_1")

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]

Player Model doc

OneSignal.getTriggerValueForKey("trigger_key");

User Model

NA

inAppMessagesArePaused

Player Model doc

OneSignal.inAppMessagesArePaused = true

User Model doc

OneSignal.InAppMessages.paused = true

setInAppMessageLifecycleHandler()

Player Model doc

OneSignal.setInAppMessageLifecycleHandler(handler)

User Model doc

OneSignal.InAppMessages.addLifecycleListener(listener)

setInAppMessageClickHandler()

Player Model doc

OneSignal.setInAppMessageClickHandler(clickHandler)

User Model doc

OneSignal.InAppMessages.addClickListener(clickListener)

Email

setEmail()

Player Model doc

OneSignal.setEmail("[email protected]")

User Model doc

OneSignal.User.addEmail("[email protected]")

logoutEmail()

Player Model doc

OneSignal.logoutEmail()

User Model doc

OneSignal.User.removeEmail("[email protected]")

SMS

setSMSNumber()

Player Model doc

OneSignal.setSMSNumber("+11234567890")

User Model doc

OneSignal.User.addSms("+11234567890")

logoutSMSNumber()

Player Model doc

OneSignal.logoutSMSNumber()

User Model doc

OneSignal.User.removeSms("+11234567890")

addSMSSubscriptionObserver() [dropped]

Player Model doc

OneSignal.add(subscriptionObserver)

User Model
NA

getSMSId() [dropped]

Player Model doc

OneSignal.Default.SMSSubscriptionState.smsUserId

User Model
NA

Outcomes

sendOutcome()

Player Model doc

OneSignal.sendOutcome("Purchase")

User Model doc

OneSignal.Session.addOutcome("Purchase")`

sendOutcomeWithValue()

Player Model doc

OneSignal.sendOutcomeWithValue(withValue: "Purchase", value: 18.76)

User Model doc

OneSignal.Session.addOutcome("Purchase", 18.76)

sendUniqueOutcome()

Player Model doc

OneSignal.sendUniqueOutcome("Swipe");

User Model doc

OneSignal.Session.addUniqueOutcome("Swipe")