-
Notifications
You must be signed in to change notification settings - Fork 62
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
iOS notifications showing in foreground #298
Comments
@roryabraham hmm that is indeed strange. The code for |
@roryabraham ok I think I see what's going on here. It's not the |
Great! Thanks! |
Hey @roryabraham, 9.0.1 is out, which has a fix for this issue. Let us know if you encounter any additional problems. |
Great! I'll adopt the patch and let you know if there are any issues. Thanks for jumping on this quickly |
Hmmm - unfortunately it looks like this didn't actually resolve my issue. After updating to |
Sorry to hear you still have the issue, we will take another look to see what else we missed. |
Thanks. Let me know if there's anything you want me to test on my side! |
@roryabraham I am unable to reproduce. The new patch seems to work great for me using your exact code:
I tested switching the value at runtime and did a cold start of the app to verify it persisted properly. You probably did, but could you verify you ran pod install after your update? We currently do not log the version of the plugin on start and the log for presentation options is logging the wrong value (dictionary instead of the integer), so the only way you can verify its using the right code is if you enable verbose logging in the airship config and look for this line:
Which gets logged when we upload analytics events (should happen within 10 seconds of a launch). |
Hi @rlepinski sorry for the long delay between replies, but even doing a |
@roryabraham Could you try to reproduce in a sample app for us? I am unable to so its hard to figure out whats going wrong. We will be doing a minor release next week, which I will make it easier to determine what version of the SDK and plugin by doing proper logging. |
@roryabraham I just released 10.0.0 with better logging, but it does require Xcode 12. If you could update, you can verify a log message saying both the SDK and react Airship version as well as better logging when the foreground presentation options change. https://github.com/urbanairship/react-native-module/blob/main/urbanairship-react-native/ios/UARCTModule/UARCTAutopilot.m#L32 It does require log level to be debug, you can set it in the AirshipConfigOptions by setting developmentLogLevel/productionLogLevel to |
Hi @rlepinski, thanks for following up again. After upgrading to 10.0.0, these are all the UA logs I'm seeing:
Then after adding this code: UrbanAirship.setForegroundPresentationOptions(_.mapObject(_.invert(NotificationOptionsIOS), () => false)); This log shows up:
Then after receiving a notification with the app in the foreground:
And the notification is still presented in the foreground. As for a sample application, we've actually just open-sourced the application that manifests this bug, and the repo for that is here. Then the relevant code all lives in here. |
We're working on streamlining things, but for now, in order to reproduce in our application, you'll have to:
As I said, we're actively working to make this process a bit easier for external contributors, but in the meantime if you have questions then the |
Looks like you have another push provider plugin that instructed you to implement the |
Could you point me to the log line that that indicated that to you? We do also use pusher-js |
The log lines all looked fine to me, so I looked at your app. Ill check out pusher-js but https://github.com/Expensify/Expensify.cash/blob/master/ios/ExpensifyCash/AppDelegate.m#L64 is going to be the reason why you get alert, badge, and sound in foreground. |
pusher-js by itself does not appear to do either remote or local notifications on its own so I think you are good. |
Okay, you figured that out impressively quickly! You were right - we use @react-native-community/push-notification-ios to handle the home-screen unread indicator for chats on iOS. I think that this means we can't safely remove this code without breaking the "unread chat indicator". So can we take you up on your offer to "check if it's an airship notification or not"? |
Could you point me to the code that uses |
Yep, super minimal use right here |
That just sets the badge number, it does not rely on any notifications. We actually have that as well for our module if you want to drop a dependency. You can delete that method in the app delegate. I forgot that detecting an Airship notification on iOS is kinda painful, ideally we dont have to do that... |
I was just wondering that! Hold on, I'll try this and see if it resolves the issue. That would be ideal for both of us 😄 |
If you need to check, I believe this works:
but I havent tested it. I can in the AM if you need it. |
Thanks for the support! This issue has been resolved! |
Preliminary Info
What Airship dependencies are you using?
Using urbanairship-react-native ^8.1.0
What are the versions of any relevant development tools you are using?
Using XCode 12.0 on physical iPhone device running 13.6.1
Report
What unexpected behavior are you seeing?
I have been working with Urban Airship in my React Native project for a few weeks, and it's working pretty well. At one point, I wanted to try to get notifications to appear in the foreground in iOS, so I added the following code:
And it worked! Notifications began appearing in the foreground. However, I am now unable to revert this action, and no matter what, notifications always appear in the foreground. I tried removing the above code, and I also tried replacing it with the following:
Each time, I ran this from the root of my React Native project:
Then did a clean build in XCode (CMD+SHIFT+K), and re-ran the app. Each time, notifications continued to appear in the foreground.
I also have no custom notifications, and nothing in my AirshipConfig.plist other than the necessary app keys
What is the expected behavior?
Notifications should not appear in the foreground by default on iOS.
What are the steps to reproduce the unexpected behavior?
Not 100% sure how to reproduce, but I would try setting all foreground options to true, then removing that same code. I assume that this is either easily reproducible, or some weird issue with some cached linked binary or something. Looking at the code for
UrbanAirship.setForegroundPresentationOptions
, it looks like setting these values to null or false might not overwrite existing values.The text was updated successfully, but these errors were encountered: