Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: OneSignal.User.pushSubscription.id is null #1450

Closed
1 task
YurchukV opened this issue Jun 17, 2024 · 1 comment
Closed
1 task

[Bug]: OneSignal.User.pushSubscription.id is null #1450

YurchukV opened this issue Jun 17, 2024 · 1 comment

Comments

@YurchukV
Copy link

YurchukV commented Jun 17, 2024

What happened?

I can't access subscriptionId , I want to use rest api in my app but I need subscriptionId for specific notification. I tried with copy subs id one signal panel thats runned not have a problem in my code, but inside the code not access have a directly subs id.

Steps to reproduce?

iOS Version 15-18
OneSignal Version 5.2.1

AppDelegate -> didFinishLaunchingWithOptions

 OneSignal.initialize(Resources.OneSignalID, withLaunchOptions: launchOptions)
 OneSignal.Notifications.requestPermission { accepted in
   print("User accepted notifications: \(accepted)")
   print(OneSignal.User.pushSubscription.id)
 }

What did you expect to happen?

Easily access subs id

OneSignal iOS SDK version

5.2.1

iOS version

17, 16, 15

Specific iOS version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@nan-li
Copy link
Contributor

nan-li commented Jul 19, 2024

Hi @YurchukV thanks for reaching out with your question.
If you are getting OneSignal.User.pushSubscription.id too early on a new app install, it will be null until the subscription ID is receieved from the OneSignal servers.

You can use the Push Subscription Observer to be notified of changes to the push subscription, including when the ID is received.

@nan-li nan-li closed this as completed Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants