-
Notifications
You must be signed in to change notification settings - Fork 376
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
[Bug]: User.optIn not working on Android #1590
Comments
Just to confirm, I have tested this on iOS and it works fine. This only happens on Android. |
@RickRedSix Before you call optOut is the user showing as subscribed on the dashboard? |
@emawby Yes they were, they had the black tick in that column.
I have also tested taking that subscriber, logging them into my app via iOS and opting them in there and it works. So it definitely seems to be isolated to Android.
|
@RickRedSix I am not able to reproduce this issue if possible could you enable verbose logging ( |
@emawby Here are the logs when
|
I'm facing with the same issue using the latest flutter sdk |
Facing the same issue here |
This is broken for a long time. Seems like one signal is not interested in react-native issues. Can somebody help to get an update whether react-native plugin is actively in roadmap ?
The above token never prints. But in the android logcat I can see below Seems like something messed up in the library |
+1 |
same issue PATCH RECEIVED JSON: {"errors":[{"code":"subscription-10","title":"Subscription can't change notification_types to positive integer while disabled"}]} Android 13 |
Downgrading to version |
In my code, OneSignal.login was being called again on re-render when the user was already registered. This was causing the issue with optIn / optOut. Once I fixed it and made sure that OneSignal.login is not called if the user is already logged in, optIn / optOut started working correctly. |
when i use OneSignal.User.pushSubscription.optIn() Please fix this as soon as possible. |
Encountering what I believe is this issue, or something maybe related, when trying to upgrade to 5.0.4. I'm using it in an Expo SDK 49 project in Android 13 on both an emulated Pixel 7 Pro and a real Pixel 7 Pro. My code, when simplified, looks something like this: OneSignal.Debug.setLogLevel(LogLevel.Verbose);
OneSignal.initialize(ONESIGNAL_APP_ID);
OneSignal.Location.setShared(false);
function refresh() {
console.log(OneSignal.User.pushSubscription.getOptedIn());
}
useEffect(() => {
OneSignal.User.pushSubscription.addEventListener('change', refresh);
return () => {
OneSignal.User.pushSubscription.removeEventListener('change', refresh);
};
}, []);
OneSignal.User.pushSubscription.optIn(); // expect to see an event fired that logs true
console.log(OneSignal.User.pushSubscription.getOptedIn());
OneSignal.User.pushSubscription.optOut(); // expect to see an event fired that logs false
console.log(OneSignal.User.pushSubscription.getOptedIn());
OneSignal.User.pushSubscription.optIn(); // expect to see an event fired that logs true
console.log(OneSignal.User.pushSubscription.getOptedIn());
OneSignal.User.pushSubscription.optOut(); // expect to see an event fired that logs false
console.log(OneSignal.User.pushSubscription.getOptedIn());
// etc. When I first run this, it works as expected, and I see a log like:
But after killing the app (swiping up on the card) and then reopening it, the event fires maybe once or not at all per opt in or out, and the opted-in state I can access is stuck either opted-in or opted-out, despite logs indicating a 200 success API PATCH operation. Here's what a restart and a couple toggles looks like:
Restarting again updates the state to reflect the correct value, but I still can't get opt-in or opt-out to subsequently update the state interactively. I wonder if something ends up in a weird state when the app gets restarted. |
Hi everyone, Thank you for your patience, continuing to report this issue, and following up with details. They are greatly appreciated. We are able to reproduce some of the behavior with I have some behavior I couldn't reproduce and would like to ask for any more details: 1. This issue @gvalenza reported:
^ Are there any more logs or reproduction steps for this particular error? I understand this error, but don't understand how it can happen. 2. Maybe unrelated to the core bug: Push Subscription Change Listener / Observer It will only fire when there is a change detected to one of the 3 properties on the push subscription: 3. @chriszs This may or may not be the same issue as |
@nan-li Yes, that's correct. Actually opting in and out work, the listener doesn't fire and the opted-in state doesn't update. I'll look at filing a separate issue. |
Moved my issue to #1625. |
Hi @nan-li |
Hello everyone! We appreciate your patience here. We recently updated the React Native SDK to include this fix. Please upgrade to 5.0.5 and let us know if you see any further issues. Thanks! |
I can still reproduce this issue on 5.0.5 and 5.0.6 |
Hi both, just commeting here as i also got the same HTTP error as @gvalenza. After looking through the rest of the logs i found this
Which was odd, so there was obviously some difficulty getting the token via the dependency So i then checked the gradle deps of my project to see what version of firebase-message was being used and saw this
In my case, the reason why the version was being pinned at 20.2.4 was due to another package intercom-react-native which also has firebase-messaging as a dependency. My project doesn't really care about push notification support for the intercom package so i pinned the dependency like so
After doing this, the one-signal sdk was able to get the token from firebase and i no longer saw that http error message and that seemed to fix a bunch of other problems i was having, like the dashboard not registering that the user had granted the PN permission I thought i would post this, just in case its helpful! |
Hi @wooller, awesome, thank you so much for giving us such detailed information! We were suspecting firebase dependency but had no real confirmation about the differences on an older vs newer version of firebase messaging, so this is extremely helpful. We recently bumped the dependency |
@nan-li upgrading to
|
What happened?
I am building a toggle to allow users to opt-out or opt-in to notifications in my app. I have successfully called User.optOut() as expected, but when testing User.optIn() it does not work. In fact, it looks like it also marks the user as opted-out. When calling optIn(), I noticed that the user's 'Last Unsubscribed' timestamp is updated to the time optIn() was called.
Here is the logic that is called when submitting:
I have checked that the right code block is being called and also checked that OneSignal.Notifications.permission is true. According to the documentation the two conditions for this to work have been met.
This isn't causing the bug, but I also noticed that the descriptions for the functions in the code are the wrong way around.
Steps to reproduce?
What did you expect to happen?
I expect the user's status to change back to Opted In.
React Native OneSignal SDK version
5.0.2
Which platform(s) are affected?
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: