Skip to content
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

Merged
merged 22 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c90fc6e
return a Promise in getScheduledLocalNotifications
lukebars Jun 10, 2020
a5cdcda
updated example/App.js
lukebars Jun 10, 2020
b76a4e4
Merge pull request #1 from lukebars/patch-2
lukebars Jun 10, 2020
9aa88d6
Create FUNDING.yml
Dallas62 Jul 1, 2020
da34ac1
Fix custom link
Dallas62 Jul 1, 2020
e37552d
Merge branch 'dev'
Dallas62 Jul 6, 2020
86af98d
Bump package.json to 4.0.0
Dallas62 Jul 6, 2020
2816253
Update CHANGELOG.md
Brianop Jul 7, 2020
1b73593
Merge pull request #1508 from Brianop/patch-1
Dallas62 Jul 7, 2020
74e9b8b
add data to android notification when scheduling
lukebars Jul 8, 2020
454af8c
"@react-native-community/push-notification-ios": "^1.3.0"
lukebars Jul 8, 2020
579ffb8
reflecting userInfo working on both platforms in documentation and ex…
lukebars Jul 8, 2020
0c828e9
Merge branch 'master' of https://github.com/lukebars/react-native-pus…
lukebars Jul 8, 2020
3e19105
revert changes
lukebars Jul 8, 2020
85952df
populate userInfo with id on both platforms
lukebars Jul 8, 2020
22d8c75
return notification id in onNotification method on iOS
lukebars Jul 8, 2020
9e84803
align onNotification on both platforms
lukebars Jul 21, 2020
9cc4167
keep notification data from fcm while populating data userInfo
lukebars Jul 27, 2020
d547687
make sure data/userInfo is an object before spreading
lukebars Jul 27, 2020
7589c4a
Apply changes to popInitialNotification.
Dallas62 Jul 27, 2020
271461e
fix popInitialNotification and null pointer
Dallas62 Jul 27, 2020
762f4c0
Fix behaviour of popInitialNotification and onNotification.
Dallas62 Jul 31, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: [Dallas62]
custom: ["https://www.buymeacoffee.com/Dallas62"]
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed


## [4.4.0] 2020-07-06
## [4.0.0] 2020-07-06

### Breaking changes

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ PushNotification.localNotification({
/* iOS only properties */
alertAction: "view", // (optional) default: view
category: "", // (optional) default: empty string
userInfo: {}, // (optional) default: {} (using null throws a JSON value '<null>' error)

/* iOS and Android properties */
userInfo: {}, // (optional) default: {} (using null throws a JSON value '<null>' error)
title: "My Notification Title", // (optional)
message: "My Notification Message", // (required)
playSound: false, // (optional) default: true
Expand Down
4 changes: 2 additions & 2 deletions example/NotifService.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export default class NotifService {
/* iOS only properties */
alertAction: 'view', // (optional) default: view
category: '', // (optional) default: empty string
userInfo: {}, // (optional) default: {} (using null throws a JSON value '<null>' error)


/* iOS and Android properties */
userInfo: {}, // (optional) default: {} (using null throws a JSON value '<null>' error)
title: 'Scheduled Notification', // (optional)
message: 'My Notification Message', // (required)
playSound: !!soundName, // (optional) default: true
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ PODS:
- React-cxxreact (= 0.62.2)
- React-jsi (= 0.62.2)
- ReactCommon/callinvoker (= 0.62.2)
- RNCPushNotificationIOS (1.2.2):
- RNCPushNotificationIOS (1.3.0):
- React
- Yoga (1.14.0)
- YogaKit (1.18.1):
Expand Down Expand Up @@ -453,10 +453,10 @@ SPEC CHECKSUMS:
React-RCTText: fae545b10cfdb3d247c36c56f61a94cfd6dba41d
React-RCTVibration: 4356114dbcba4ce66991096e51a66e61eda51256
ReactCommon: ed4e11d27609d571e7eee8b65548efc191116eb3
RNCPushNotificationIOS: 4c97a36dbec42dba411cc35e6dac25e34a805fde
RNCPushNotificationIOS: d5fd66aed4e03c6491ca0c6111a03d4f6455ff6c
Yoga: 3ebccbdd559724312790e7742142d062476b698e
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 56c2537f71f3f02200d6918c542a8e89a0b422fa

COCOAPODS: 1.9.1
COCOAPODS: 1.9.3
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"pod-install": "cd ios && pod install"
},
"dependencies": {
"@react-native-community/push-notification-ios": "^1.2.2",
"@react-native-community/push-notification-ios": "^1.3.0",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-push-notification": "git+https://[email protected]/zo0r/react-native-push-notification.git"
Expand Down
37 changes: 23 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ Notifications.localNotification = function(details) {
}
}

if (details.userInfo) {
details.userInfo.id = details.userInfo.id || details.id;
} else {
details.userInfo = {id: details.id};
}

if (Platform.OS === 'ios') {
// https://developer.apple.com/reference/uikit/uilocalnotification

Expand All @@ -161,12 +167,6 @@ Notifications.localNotification = function(details) {
soundName = ''; // empty string results in no sound (and no vibration)
}

if (details.userInfo) {
details.userInfo.id = details.userInfo.id || details.id;
} else {
details.userInfo = {id: details.id};
}

// for valid fields see: https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html
// alertTitle only valid for apple watch: https://developer.apple.com/library/ios/documentation/iPhone/Reference/UILocalNotification_Class/#//apple_ref/occ/instp/UILocalNotification/alertTitle

Expand All @@ -190,6 +190,10 @@ Notifications.localNotification = function(details) {
}
}

if(!details.data && details.userInfo){
details.data = details.userInfo;
}

if (details && typeof details.shortcutId === 'number') {
if(isNaN(details.shortcutId)) {
console.warn('NaN value has been passed as shortcutId');
Expand Down Expand Up @@ -224,19 +228,19 @@ Notifications.localNotificationSchedule = function(details) {
}
}

if (details.userInfo) {
details.userInfo.id = details.userInfo.id || details.id;
} else {
details.userInfo = {id: details.id};
}

if (Platform.OS === 'ios') {
let soundName = details.soundName ? details.soundName : 'default'; // play sound (and vibrate) as default behaviour

if (details.hasOwnProperty('playSound') && !details.playSound) {
soundName = ''; // empty string results in no sound (and no vibration)
}

if (details.userInfo) {
details.userInfo.id = details.userInfo.id || details.id;
} else {
details.userInfo = {id: details.id};
}

const iosDetails = {
fireDate: details.date.toISOString(),
alertTitle: details.title,
Expand Down Expand Up @@ -277,6 +281,10 @@ Notifications.localNotificationSchedule = function(details) {
details.shortcutId = '' + details.shortcutId;
}
}

if(!details.data && details.userInfo){
details.data = details.userInfo;
}

if(details && Array.isArray(details.actions)) {
details.actions = JSON.stringify(details.actions);
Expand Down Expand Up @@ -336,12 +344,13 @@ Notifications._onNotification = function(data, isFromBackground = null) {

if ( this.onNotification !== false ) {
if ( Platform.OS === 'ios' ) {
const notifData = data.getData();
this.onNotification({
id: data?.userInfo?.id,
id: notifData?.id,
foreground: ! isFromBackground,
userInteraction: isFromBackground,
message: data.getMessage(),
data: data.getData(),
data: notifData,
badge: data.getBadgeCount(),
alert: data.getAlert(),
sound: data.getSound(),
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-push-notification",
"version": "3.5.2",
"version": "4.0.0",
"description": "React Native Local and Remote Notifications",
"main": "index.js",
"scripts": {
Expand All @@ -24,7 +24,7 @@
"url": "git+ssh://[email protected]:zo0r/react-native-push-notification.git"
},
"dependencies": {
"@react-native-community/push-notification-ios": "^1.2.2"
"@react-native-community/push-notification-ios": "^1.3.0"
},
"peerDependencies": {
"react-native": ">=0.33"
Expand Down