-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Populate userInfo on android, update RNCPushNotificationIOS #1516
Conversation
* dev: (48 commits) Release v4.0.0. Use SecureRandom and remove `onNotification` call for Scheduled notifications when there is no user interation. Update CHANGELOG.md replaced java.util.Random with java.security.SecureRandom in RNPushNotification.java Remove WAKE_LOCK from documentation. zo0r#1494 Add `onRegistrationError`. Allow override the channel name and description in App. Add the detection of blocked channels. Fix notif reference undefined. Fix typo. Add notification id to iOS if userInfo doesn't exist `userInfo` is now populated with id by default to allow operation based on `id` "@react-native-community/push-notification-ios": "^1.2.2" add docs add example button to log scheduled notifications bump @react-native-community/push-notification-ios to v1.2.1 format date for scheduled notifications object map scheduled local notifications to united return object for both platforms add missing getters for notification attributes change naming of notification params returned on android, return date in unix timestamp as before format android getScheduledLocalNotifications return object to match iOS return object ...
Fixed version from 4.4.0 to 4.0.0
Update CHANGELOG.md
cc @Dallas62 |
Hi @lukebars |
@Dallas62 did you manage to look into it? |
Will check this this afternoon |
Hi @lukebars |
Hmmm. I'll check that in few hours. Very strange. |
@Dallas62 thing is that iOS returns I could remove |
I will take a close look to this, because it's strange to set |
Hi @lukebars I'm not totally convinced by this kind of "renaming" as an optimal solution, but it's probably the best way to unify Android and iOS actually. So, no problem to remove In the future, I think we should rewrite the API to unify and clean it. Also make a clear documentation. 😄 |
@Dallas62 or we could currently use |
Not sure it's better, because this is the name of the attribute of remote notifications. |
Ok, sure. |
Looks good |
Are we ready for some sort of release? |
Hi @lukebars |
Hey @Dallas62, I've noticed a strange behavior on android that comes from When app is launched from killed state / fresh launch, and you schedule a first notification, I see that if you comment out Was it intentional to do this or is it a bug? |
@lukebars This is strange, I don't see this behavior |
This comment has been minimized.
This comment has been minimized.
Can you test on the example project (without change expect setting the PR), if his is happening this is probably in the library. In your code, does |
This comment has been minimized.
This comment has been minimized.
Can you give the steps to reproduce it on the example project ? |
This comment has been minimized.
This comment has been minimized.
I don't see any problem, does the log: console.log('NotificationHandler:', notification); inside NotifSetup is right ? it's written |
This comment has been minimized.
This comment has been minimized.
Yes it's logged twice the notification, but the example Application has the same console.log in NotificationHandler and in the NotifSetup you provided, which explain this behavior |
@Dallas62 Oh I was wrong about that 🤦 I've actually managed to reproduce it now. We're using branch in our projects for analytics and it requires setting intent. It's easy to reproduce with only a minor change in repo example too: package com.example;
// Add this:
import android.content.Intent;
public class MainActivity extends ReactActivity {
// Add this:
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent); // this is what causes double onNotif call when scheduling one on a fresh launch and clicking it
}
// Everything else
... |
This comment has been minimized.
This comment has been minimized.
Hi @lukebars A correct change would be: AppState.addEventListener('change', (state) => {
handlePopInitialNotification(state);
}); But you will see the same result. There is a protection to block double trigger based on |
@Dallas62 eh, my bad. Both onNotification messages fire with Looks like if |
What is strange is that you are talking about double trigger even when you comment this._onNotification(firstNotification, true); But it's impossible to get |
Nope. When that line is commented out, it get triggered only once on Android. Have you tried adding
to Instant double call without any code modification inside the lib. |
I'm currently testing it, and I found the reason of that. Making more tests. |
That explains everything. Looks like it's doing the same thing as the js initial notif part, only a bit worse. Nice catch 🚀 |
Yes but it's probably not so easy. on iOS, clicking on a notification when the Application is opened doesn't trigger the current part of "initialNotification", only Android do that |
Also, the value of |
Fix foreground value.
I think it's good now 😉 |
@Dallas62 awesome work! Tested it out and it looks really good 🚀 Are we getting close to closing this and releasing it out to the daylight? |
Hi @lukebars |
Done ✅ Found the same issue you reported on iOS while testing 😄 Thanks a lot for this PR ! |
This aligns the object returned by
onNotification
.Currently
onNotification
returns:As you can see iOS returns
userInfo
asdata
, and android returnsuserInfo
asuserInfo
. Also - id is not being correctly populated on iOS.My proposal would return this object
onNotification
:This would also allow us to provide data when getting scheduledNotifications, which I would implement little bit later. P.S. currently on iOS alert(title) is wrong, that's because iOS doesn't return notification title. I will raise a PR in RNC repo for that. Naming should be tweaked too (android - title, iOS - alert). Another possible solution would be naming
data
asuserInfo