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

[question]: How does one fetch the "optedIn" status for a user? #76

Closed
1 task done
kpturner opened this issue Jan 15, 2024 · 1 comment
Closed
1 task done

[question]: How does one fetch the "optedIn" status for a user? #76

kpturner opened this issue Jan 15, 2024 · 1 comment

Comments

@kpturner
Copy link

How can we help?

The mobile app SDK has two methods: OptIn and OptOut to specify whether the user is opted in to receive push notifications or not. There is also a optedIn method to find out what the value is.

How do I fetch that value with onesignal-node-api ?

Code of Conduct

  • I agree to follow this project's Code of Conduct
@iAmWillShepherd
Copy link

You can access the subscription property from the user's subscriptions then pluck out enabled

Something like this👇🏽

const { subscriptions } = await OneSignal. fetchUserAsync('APP_ID', 'ALIAS_LABEL', 'ALIAS_ID')

subscriptions.map(subscription => { 
  const {enabled } = subscription
  // do stuff with this info
}) 

I'm assuming you already know the Subscription ID you're after, so change map to whatever function you like.

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