简体   繁体   中英

OneSignal Unsubscribe playerID flutter

In my case: I have 2 options to push:

  1. Use Player ID
  2. Use Segment

I want to unsubscribe only Player ID, and keep Segment

I've seen:

  1. OneSignalServices.instance.disablePush(true) => But it disable all my pushes.
  2. Delete user via API:
 curl --include \ --request DELETE \ --header "Authorization: Basic YOUR_ONESIGNAL_API_KEY" \ https://onesignal.com/api/v1/players/ONESIGNAL_PLAYER_ID?app_id=YOUR_APP_ID

But follow the OneSignal document I need Uninstall the app and re-install the app.

How to do it when the user signs out?

Don't send notifications based on player Id instead use an external User Id to send notifications and map your player Id with an external User Id.

In your case, the external User Id will be a random string generated at the time of login and stored in the database as a notification token. Then map this token with the player Id and when the user will logout just delete this token from the database.

Steps Involved:

  1. On user login
  1. On user logout
  • Delete notification token from your database

Hope this help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM