-
Notifications
You must be signed in to change notification settings - Fork 61
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]: OneSignal 5.0 iOS PushSubscription.Id crash and PreventDefualt still displaying on iOS #628
Comments
Thanks for bringing this up! This is a problem in 5.0.0 and has been fixed in the 5.0.1 Release. Let us know if you have any questions or if the issue is still occurring |
Hey @shepherd-l 👋 However, I still cannot find a way to properly disable pushes while the app is in foreground.
Then, in C# code, I just use:
but this still doesn't give me good results, as they push is just being delayed 25 seconds, which is the timeout period set somewhere I couldn't figure out where. Here's the log:
Not sure where to find the timer that times out. |
Thank you for the detailed message! I agree with the changes you made in ObjectiveC++, we will be creating another release soon with the same changes In C#, the ForegroundWillDisplay delegate should be added to call event.PreventDefault So instead of
It should be:
Let us know if that fixes the issue for you |
@shepherd-l yeah, sorry, I copied wrong part of the code. I use
|
Is the notification still displaying in the foreground? If so, could you please provide your entire log A notification with a display type of 0 means the notification will not be displayed. The 25 seconds timeout should always occur after PreventDefault. We wait to check if Display is called after PreventDefault to allow notifications to be modified and then displayed. |
Yes, it appears in foreground after this 25 second delay |
@shepherd-l the only thing I get in the logs is this:
and I still get the notification in foreground after the delay |
Are you using any other SDKs in your project? What version of Unity and Xcode are you using? What devices and their iOS versions are you seeing this issue on? I was unable to reproduce the issue myself - if you have time, could you try reproducing this issue in a new project and share the steps and project with us |
@shepherd-l |
@mpiechocki |
@shepherd-l hmm, I tried to create a vanilla project to reproduce the issue and noticed some weird behaviour:
Which kind of gives me the idea that something might be wrong with the configuration or subscriptions. I recently have been testing the pushes on those two phones many times, on many different app versions and such. What do you think? |
If the same user is logged into multiple devices then each device would have its own push subscription attached to the user. On the dashboard it would look something like this:
Visualizing user x would be something be like:
In the SDK, calling How are you sending the notification? Is phone B also logged into the same user as phone A? Let me know if I can clarify anything |
Thanks for thorough explanation. I'm logged on two different accounts while testing. I guess my question would be: is it possible that one device would have 2 simultaneous subscription for one user? I'm sort of blind guessing now, but I'm really confused by the results I'm getting |
On OneSignal.Initialize("app_id") and when consent is given for push notifications, the SDK requests a push token for the device and creates a Push Subscription with it. It is possible that we cannot get a token from APNS but we don't need one in order to create a Push Subscription. In that case we may receive it later and will update the Push Subscription with the token. A Push Subscription without a push token can still receive in app messages. Sorry for that mix up, I will remove it from my last post. A device only has one unique Push Subscription in each OneSignal app that initializes. If an end user uninstalls and reinstalls the app, opens the app and initializes OneSignal, a new push token will be requested and a new Push Subscription will be created for the app for the device. Sending a notification to the old Push Subscription Id will not display notifications on the device because the Push Subscription has changed. Glad I can help. I'm not sure if I answered your question, let me know if I missed anything |
Thanks @shepherd-l ! |
Np! Thanks for bringing attention to these bugs and even diving in to find a fix. We plan to release the patch early next week |
@shepherd-l |
After some more testing, I figured out that if I spam push notifications while app is in foreground, then I'll get only the last push (after 25s delay). When app is in background, everything is fine, I get all the pushes |
The other thing I found is:
We're using Singular SDK also, can it be problematic? |
Ok, one more thing that might shed more light onto the problem:
somewhere in the C# code. If this callback is added, Unity will prevent notifications from appearing while in foreground. |
I couldn’t reproduce the issue - I created a new project with just the OneSignal SDK and the fix. Could you try creating a new project with only the OneSignal SDK and see if PreventDefualt still doesn’t work? If you are still able to reproduce the issue, could you share the project with us If the issue does not occur, I suspect that there is a conflict with OneSignal and another SDK you are using. You mentioned the Singular SDK, could you clarify to make sure |
@shepherd-l I'm currently off, but I'll try to reproduce it once I'm back :) |
How can we help?
General question is: how do I initialise OneSignal Unity SDK properly on iOS, in version 5.0.0? I'm using OneSignal for pushes only.
What I'm currently doing, is that after logging user in, I need to set the subscription id to our server, so that it can authorise the pushes properly.
The initialization code is as follows:
And then, when the session is opened, and I know the user, I call:
The problem is that on Android, this code works just fine and pushes work as expected. But on iOS, this results in a runtime crash:
I tried to guard against nulls, but still, the result is the same. I tried to look into OneSignal objc code and found something that worries me a little bit:
as the propery name is
id
which is a keyword in objc, but I'm not actually sure it's the problem.Can anybody point me to any direction on what might be an issue here? Thanks!
P.S. The problem we're trying to actually solve with upgrading to 5.0.0 is that we still didn't find a workaround for getting pushes in foreground bug (see #521) so if anyone has any workaround for this on OneSignal 4.8.3, I'd be happy to hear it :)
Code of Conduct
The text was updated successfully, but these errors were encountered: