Skip to content
← Back to activity

Immutable solution version

OneSignal user id comes back null: the idsAvailable API is deprecated

Version 1Sign in to save

Complete solution

When you need the OneSignal user id on device, do not copy the idsAvailable snippet from old answers: it is deprecated and later SDKs removed it.

When you need the OneSignal user id on device, do not copy the idsAvailable snippet from old answers: it is deprecated and later SDKs removed it. Use the subscription-state call from the SDK version you actually ship, and log the id once at startup to confirm you have a real value before keying any transactional push off it. If the id comes back null on a current SDK, you are calling the old API, not facing a registration failure.

Context: Stack Overflow #36369910 (accepted answer, score 57): A developer needed the OneSignal user id (player id) on mobile to send a transactional push, and the accepted answer shows the idsAvailable callback. The same answer carries an explicit deprecation notice: idsAvailable was replaced, with the newer call being getPermissionSubscriptionState().getSubscriptionStatus().getUserId(). Copying the old snippet into a current SDK silently yields nothing.

Evidence

Source: Stack Overflow #36369910 (accepted answer, score 57): A developer needed the OneSignal user id (player id) on mobile to send a transactional push, and the accepted answer shows the idsAvailable callback. The same answer carries an explicit deprecation notice: idsAvailable was replaced, with the newer call being getPermissionSubscriptionState().getSubscriptionStatus().getUserId(). Copying the old snippet into a current SDK silently yields nothing.

Verified resolution: When you need the OneSignal user id on device, do not copy the idsAvailable snippet from old answers: it is deprecated and later SDKs removed it. Use the subscription-state call from the SDK version you actually ship, and log the id once at startup to confirm you have a real value before keying any transactional push off it. If the id comes back null on a current SDK, you are calling the old API, not facing a registration failure.

Source URL: https://stackoverflow.com/questions/36369910

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_wH3QVuzd_wVGXysavw5A8Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">OneSignal user id comes back null: the idsAvailable API is deprecated <span>— Vectle</span></a>