Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable OneSignal on android?

I want to use OneSignal on my app to send notifications to my users, and it is well documented and good, you should just act like this:

https://documentation.onesignal.com/docs/android-sdk-setup

OneSignal.startInit(this)
    .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
    .unsubscribeWhenNotificationsAreDisabled(true)
    .init();

The problem is, I want to just send notification to my logged in users, so if a user logged out, I dont want him to receive notification, how can I disable OneSignal after it's inited?

I don't want to handle this on server, it should be some way to stop OneSignal service, I think.

like image 924
Ali Molaei Avatar asked Apr 10 '18 13:04

Ali Molaei


People also ask

What apps use OneSignal?

Limitless Integrations OneSignal integrates with leading analytics, CMS, and eCommerce solutions including Amplitude, Mixpanel, Segment, HubSpot, Shopify, WordPress, and many more.

What is OneSignal used for?

OneSignal is a service that enables push notifications, abstracting details such as the platform the device is running on. With the OneSignal plugin, OutSystems applications can send and receive push notifications. The image below shows a push notification in an Android smartphone.


1 Answers

OneSignal has something called segments... (flags).

You can set a flag with OneSignal. If the user is logged in, they belong to a flag that logged out users don't.

For example, if logged in, set a flag for OneSignal as loggedin. If logged out, set the flag for OneSignal for this user as loggedout. When you send out notifications, you only send it to the loggedin flag.

like image 141
letsCode Avatar answered Oct 04 '22 02:10

letsCode