-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
Push Notification - iOS & Android Updates! (Now includes FCM - Fuse 1.10+) #1220
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In iOS/Impl.uno, the code will work today but will fail when the deprecated method registerUserNotificationSettings
is removed from iOS. At that time, the if (..respondsToSelector..)
clause will not execute and the else
clause will crash the app due to the no longer existing method call registerForRemoteNotificationTypes
.
I would recommend that you test first for the existence of the new API (iOS10+) with:
UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
if ([center respondsToSelector:@selector(requestAuthorizationWithOptions:)]) {
// Now in iOS10+ land
[center requestAuthorizationWithOptions: ... same code ....]
else {
// Now in pre-iOS10 land
[application registerUserNotificationSettings: ....
}
Also, in the completion callback, if you add a test for granted
then registration with APNS will not occur if the user declines to give permission:
[center requestAuthorizationWithOptions: (alert | sound | badge)
completionHandler: ^(BOOL granted, NSError * _Nullable error) {
if (granted) {
[application registerForRemoteNotifications];
}];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @ekkotech, thanks for the feedback, yeah, the goal of this pr was to enhance the existing code to get it functional as it really isn't working as it stands. iOS Issue1: I like your fallback logic, I didn't write the original but I'll enhance it with yours. My issue with #1197 : I couldn't get it to work. I really tried, maybe there's something different between our setups, ionno, and the PR didn't seem to be moving. So I would say the main differences are that I broke my PR's into separate bite-sized issue resolutions; for instance the map one is a critical breaking fix, so I don't see why that needs to be held up. Ok, so the summary break down: iOS fix - push notifications are silent right now because we don't explicitly ask for permission Android fix - Android 8+ compatibility |
@ekkotech I just updated the iOS check for versions older than 10 |
e80073d
to
fd79d92
Compare
27 Sep - iOS & Android: Push Notification Fixes + Features Android Fixes - Added default Notification Channel, so won't have to compile for API 25 to get push notifications working. - Can configure the default channel name via unoconfig Features - Added setting of icon color / app name - Can set color via unoconfig & notification payload - Added the ability to hide the title via unoconfig iOS Fixes - Explicitly ask for permission so notifications won't be silent - Updated version check Feature - Added function to get whether or not the user has push notifications turned on or off 28 Sep - Added Push Notification Features Android - Notification Category - Notification Color - Notification Lockscreen Visibility - Notification Priority - Notification Sound - No Title Style Android 8+ - Notification Channel - Nofitication Channel Group - Notification Channel Importance - Notification Channel Lockscreen Visibility - Notification Channel Light Color - Notification Channel Sound - Notification Channel Show Badge - Notification Channel Vibration - Notification Badge Number - Notification Badge Icon Type 1 Oct - Added documentation for how to implement the new android push notification features in fuse
Why was this closed? |
@AndrewEQ re. iOS issue2: I see where you are coming from and, from a technical standpoint it has merit, but if you look at it from a data security standpoint, I have two concerns. 1) You are leaking a user's data out to APNS when the user's expectation is privacy, 2) this is library code; applications built on top of this will get a response back from APNS and go ahead and push that out to their own application server. Now there is nothing stopping the user from getting push notifications when they said they didn't want them. |
@ekkotech 1) I know what you're thinking but I've tested it, the notifications are turned off for the user when they say no in the dialog. 2) It was doing this, and still is before my updates. That's where I got the initial idea from. Difference is that the current implementation is silent even when the user says "yes". From my tests and according to the Apple docs: Scenario 1 + 1.1 - current code Scenario 1:
Scenario 1.1:
Scenario 2 + 2.1 - new code Scenario 2:
Scenario 2.1:
|
@AndrewEQ Question for you: when you were testing your code changes, what key did you use when sending to GCM? For example, here is the script that I use for pre-API26 tests: `#!/bin/bash curl -X POST |
hey @ekkotech, this was the payload structure that I was testing with: https://github.com/fuse-open/fuselibs/pull/1220/files#diff-0aae1bdd92b0184bb9df83ff47aa3973R230 |
@ekkotech were you able to get your notification? |
…ush-Notifications
edaada1
to
ae30a34
Compare
…ush-Notifications
- updated android gcm components with fcm components - added function to update token if refreshed - updated play services detection - updated MapView dependency (its too old) - updated color & lightcolor to allow for with or without #
Updated with FCM support! 🎉 |
Fix for iOS 8-9 push notifications
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should create another PR for map fix because that fix is nothing to do on what PR title said
I guess I needed it as well at the time cos maps was needed too, else the compilation broke without it. |
Ah, I see. But since there is an issue posted on forums about MapView is crashing when targeting Android 9, and the fix for it is on this PR by this commit. But this PR is not yet merged by reviewers. So my recommendation is to create another PR just to fix the MapView Issue. Since the fix is so simple, I think that PR will merge immediately by @kusma |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on Android and iOS
19 Jun 2019 - iOS
Fixed push registration for iOS 8-9 devices
16 Nov - Android: Updated from GCM to FCM! :)
Android.uxl
27 Sep - iOS & Android: Push Notification Fixes + Features
Android
Fixes
Features
iOS
Fixes
Feature
28 Sep - Added Push Notification Features
Android
Android 8+
This PR contains: