-
-
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
Update Fuse.PushNotifications module to work with Android 8 and keeping backward compatibility #1197
Conversation
intent.setAction(PushNotificationReceiver.ACTION); | ||
intent.replaceExtras(payload); | ||
android.app.PendingIntent pendingIntent = android.app.PendingIntent.getActivity(context, id, intent, android.app.PendingIntent.FLAG_UPDATE_CURRENT); | ||
android.app.PendingIntent pendingIntent = android.app.PendingIntent.getActivity(context, 0, intent, android.app.PendingIntent.FLAG_ONE_SHOT); |
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.
This seems to undo a recent fix... why is this needed?
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.
would please explain why this important ? I dived in but understood nothing about this code so i got it back to the defaults
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.
getting it back isn't a problem as long as there's a reason behind it
sorry for the inconvenience though
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.
The PR for that change contains an explanation: #1185 (comment) :)
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.
We don't just undo someone else's work without reason.
@@ -296,29 +301,42 @@ namespace Fuse.PushNotifications | |||
[Foreign(Language.Java)] | |||
static void SpitOutNotification(Java.Object _listener, string title, string body, string bigTitle, string bigBody, string notificationStyle, string featuredImage, string sound, Java.Object _payload) | |||
@{ | |||
int id = PushNotificationReceiver.nextID(); | |||
Log.d("Android Impl", "SpitOutNotification"); |
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 doubt you want to have this change...
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.
same as previous comment
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.
Maybe I wasn't clear. I meant that introducing a debug-log here seems pretty pointless. The moving of the nextID-call is a separate matter.
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); | ||
notificationBuilder.setSound(defaultSoundUri); | ||
} | ||
} |
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.
This block seems to have some indentation issues...
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'm using tabs for Indentation, is it good?
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.
The last level of indentation here is done with spaces, not tabs. I suggest you enable visible white-space in your text-editor, and you'll see what's up...
@@ -41,7 +41,7 @@ namespace Fuse.PushNotifications | |||
"registrationSucceeded") | |||
{ | |||
if (_instance != null) return; | |||
Resource.SetGlobalKey(_instance = this, "FuseJS/Push"); | |||
Uno.UX.Resource.SetGlobalKey(_instance = this, "FuseJS/Push"); |
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.
This seems unrelated to this commit...
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.
without Uno.UX
part, compiler shows Resource is ambiguous
. If you're certain it can work without any error we can revert this change to the old thing
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 don't see anything in this commit that introduces this ambiguity, so I don`t think this is the correct commit to do this in. Please correct me if I'm wrong.
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.
This is the error that I'm encountering for Resource
Fuse.PushNotifications/JS.uno(44,5): Error E3109: 'Resource' is ambiguous
Candidates are: Uno.UX.Resource
Fuse.Reactive.Resource
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.
Hmm, this sounds familiar. Does this also happen before this patch-series? If so, it probably deserves its own fix, and possibly a back-port...
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.
Yes
this happens to me before this patch-series
Please keep aware for my change about intent flags. |
Depending to my experience, we have to deprecate this module totally and try to use this one |
@kusma will be updating the commit soon and get it ready to be merged. but i think you should have a section in the README file the talks a little bit about commit message. |
@devadiab You're changes was kept. regarding firebase plugin i don't it's not compatible with Android 8 (tested) plus official documentation show's that the compatible version is |
@helilabs i see that, i was emphasizing for that. you have good efforts but its the time to fully run on Firebase FCM not GCM anymore |
Also the Android 8+ not allowing the pending intent for GCM anymore ! |
@helilabs: Details about how to commit etc live in CONTRIBUTING.md; feel free to send a PR with clarifications there if you think something is missing. I agree that we're not talking much about that there as-is, so there's some undocumented expectations ATM. |
@kusma commits are now updated and sorry for being late |
This seems to have broken around a year ago, yet nobody seems to have noticed until now.
…cation new updates
@devadiab @mohammedmanssour how bout we make a separate module for firebase push notifications? Perhaps call it "Fuse.FirebasePushNotifications"? |
Hey guys, what be happening with this? |
FYI: for others looking to get push working in Android 8 until new features are fulfilled: https://forums.fusetools.com/t/getting-push-notifications-to-work-in-android-8-with-super-little-change/7423 |
Both of these files uses both Uno.UX and Fuse.Reactive (which both provides a Resource class), but neither clarify which one they want to use. This leads to a compilation error on usage. So let's fix it, by adding the fully qualified name here. How this has gone unnoticed for this long is beyond me. I guess nobody is using this functionality? This was extracted out of fuse-open#1197, but another case was added as well.
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.
Today, I tested this commit plus a5052b2 and d7bb8eb (this last one not related to Push Notifications but I included it anyway) on an Xperia XZ1 Compact running 8.0 (26). Set up to perform the testing was:
- Clean install of Fuse 1.9
- Clean install of Android (uno install android)
- Update of platforms and build tools using sdkmanager (platforms 16 though 28); build-tools (26.0.3, 27.0.3, 28.0.3)
- Replaced NDK 18 with 17c
- Local copy of latest fuselibs as of 29th Sept.
- Merged these commits into local copy of fuselibs
- Project .unoproj:
-
- BuildToolsVersion: 28.0.3, CompileVersion: 28, MinVersion: 16, TargetVersion: 26
-
- New notification tags: "Name", "Description", "ChannelID"
- Test notifications fired from curl script (to GCM)
- Ran the test with uno build mytest.unoproj -t=android -c=release --run
Result: worked without any changes. Icon dot came up as expected, notifications came through to system tray or application depending on whether application was in foreground or not.
Observation: I could not create a situation where the notifications did not work. For any combination of ChannelID (in .unoproj) and channel tag in payload, notifications always came though. Deliberately mis-matching the channel id names or removing channel id completely from .unoproj had no effect - it still worked. I need to test more but it looks to me as if GCM ignores any channel id that you provide - possibly only FCM actually manages that data item. If this is the case, then channel id and all the other options available under 26+ cannot really be tested until fuselibs supports FCM. Having said that, it looks to me that this is a good "baseline" for supporting 26+ with GCM (the background fix is important and the icon dot is nice to have)
I have another test slot coming up on Friday so I'll try more variations then.
Closed. Fixed in ae566ac |
Hello!
Previously Push Notifications caused app crashes on Android 8 because Android 8 isn't supporting background jobs anymore
JobIntentService
that can be scheduled and works well with all version of Android instead of plainService
NotificationChannel
logic That is required by Android 8 in order for notifications to function well.Fuse.Maps
dependencies to avoid conflict with the newFuse.PushNotifications
That's all,
Thanks