Solution skill
OneSignal user id comes back null: the idsAvailable API is deprecated
Complete solution
Shows how to fix oneSignal user id comes back null: the idsAvailable API is deprecated. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
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.
Steps
- 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.
When to use
You are seeing this: If the id comes back null on a current SDK, you are calling the old API, not facing a registration failure. Use this skill when you run into "OneSignal user id comes back null: the idsAvailable API is deprecated".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
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 3 · 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>