post https://onesignal.com/api/v1/players/:id/on_session
Update a device's session information
This method should be called when a device opens your app after they are already registered. This method will automatically increment the player's session_count
, and should also be used to update any fields that may have changed (such as language or timezone).
If a player record is not found, a new one will be created if and only if the request includes a device_type.
Body Parameters - New session
Parameter | Type | Description |
---|---|---|
identifier | String | Recommended Push notification identifier from Google or Apple. For Apple push identifiers, you must strip all non alphanumeric characters. Example: ce777617da7f548fe7a9ab6febb56 |
language | String | Recommended Language code. Typically lower case two letters, except for Chinese where it must be one of zh-Hans or zh-Hant . Example: en |
timezone | Int | Recommended Number of seconds away from UTC. Example: -28800 |
game_version | String | Recommended Version of your app. Example: 1.1 |
device_os | String | Recommended Device operating system version. Example: 7.0.4 |
ad_id | String | Recommended The ad id for the device's platform: Android = Advertising Id iOS = identifierForVendor WP8.0 = DeviceUniqueId WP8.1 = AdvertisingId |
sdk | String | Recommended Name and version of sdk/plugin that's calling this method. |
tags | Object | Custom tags for the player. Only support string key value pairs. Does not support arrays or other nested objects. Example: {"foo":"bar","this":"that"} |
device_type | Int | If included, will create a new player record if the one is not found. Possible values are the same as device_type in the add device call |
Example Code - New session
curl --include \
--request POST \
--header "Content-Type: application/json" \
--data-binary "{\"language\":\"es\",
\"timezone\":-28800,
\"game_version\":\"1.0\",
\"device_os\":\"7.0.4\"}" \
https://onesignal.com/api/v1/players/:id/on_session
Result Format - New session
{"success": true }