React-native-onesignal: OneSignal requires launchMode as "singleTop" while Auth0 requires it as "singleTask"

Created on 14 Jun 2018  路  22Comments  路  Source: OneSignal/react-native-onesignal

Description:
I have used Auth0 in my react-native-app.Now i want to integrate OneSignal which requires launchMode as "singleTop" in AndroidManifest.xml.But Auth0 also requires launchMode to be set as "singleTask".Is there any way to add 2 launch modes?

Documentation

All 22 comments

@sksahil030 Unfortunately, yes, singleTask can result in multiple instances of our SDK which can cause significant issues.

You _can_ still use singleTask for _other_ activities in your app, but the main activity must be singleTop (or any other launch mode that cannot result in duplicated screens)

@sksahil030 How did you add 2 launch modes to the AndroidManifest, I'm encountering the same issue as you with Auth0 and OneSignal.

any help you can offer is much appreciated, thanks in advance

@chiaberry Sorry, but I was not able to find any solution for this

@Nightsd01 is this still true? I need singleTask for another lib in my app

We are experiencing exactly the same issue with the OP. Auth0 + OneSignal...
Any solution or workaround would be much appreciated.

Why is this issue closed? Is there a solution to this?

Hello everyone, unfortunately, this isn't something that we have a ton of bandwidth to focus on so we will not be focusing on a workaround for now. If anyone else is able to come up with a workaround, we would love to hear it! I will flag this as an enhancement and track it internally so we can retake an effort to solve this in the future.

i change to SINGLETASK then i try create message.
in background and foreground notif is showing without any problem.
is there any issue we have to concern if we change to SINGLETASK??

Howdy,
Unfortunately, yes, singleTask can result in multiple instances of our SDK which can cause significant issues. See this comment

That comment was a year ago, is it still valid?
And not specifically describe what is the issue, I cannot sent notifications in some cases or what?
I see in other post issue which was used same solution, change to singletask.

https://github.com/geektimecoil/react-native-onesignal/issues/701

Thanks for your explanation.

@rgomezp Still an issue here. Is there a way to make OneSignal work reliably with singleTask? As per React Native documentation (https://facebook.github.io/react-native/docs/linking) even Linking itself requires the MainActivity launchMode to be singleTask. Is there away around this for OneSignal?

I also posed the same question on the following closed issue: https://github.com/OneSignal/react-native-onesignal/issues/701#issuecomment-553563510

We plan to fix this eventually. Currently, there is no way around this and the explanation from that issue is still true

Yes, everyone just using singleTask.
Personally I'm not found any problem yet, onesignal notifications works, linking works.

We plan to fix this eventually. Currently, there is no way around this and the explanation from that issue is still true

Is there an ETA for this?

No ETA currently

@rgomezp Can we keep a single issue open for this until the fix lands?
Multiple issues for this have already been closed (but not resolved). It would be nice to have a place to track it.

Hi again, is this by any way affected by the new way of initializing the SDK as stated in the 3 documentation?

Howdy @xeroxoid ,
No these are unrelated.

The main thing we are trying to prevent with these flags is multiple instances of the main Activity which could lead to multiple instances of React Native itself.

After reading through Android's Activity docs in more detail singleTask is what should be used since it will never create multiple instances. That is because singleTop can create a new Activity instance if it isn't on the top of the stack already.

We have updated the OneSignal React Native setup guide to use singleTask since this discovery.
https://documentation.onesignal.com/docs/react-native-sdk-setup

The main thing we are trying to prevent with these flags is multiple instances of the main Activity which could lead to multiple instances of React Native itself.

After reading through Android's Activity docs in more detail singleTask is what should be used since it will never create multiple instances. That is because singleTop can create a new Activity instance if it isn't on the top of the stack already.

We have updated the OneSignal React Native setup guide to use singleTask since this discovery.
https://documentation.onesignal.com/docs/react-native-sdk-setup

What is that mean?
OneSignal developer did a mistake years ago when they wrote singleTop in the documentation?
Because that was why we used singleTask in the first place, to make our apps one instance only.
But thanks for this clarification.

@hotaryuzaki Correct, in most cases singleTop did work for React Native unless you use a library that shows it's own Activity AND only if the user taps on a OneSignal notification while your app has the library's custom Activity on the top of the back stack.

Due to this specific case edge OneSignal's developers did not see an issue with singleTop at first. So now we recommend only using singleTask to avoid any possible issues.

Update, as of react-native-onesignal 4.0.4 a android:launchMode setting is no longer required for OneSignal.
You can use whichever android:launchMode setting you need (or none at all).

Was this page helpful?
0 / 5 - 0 ratings