diff --git a/Examples/simple-fcm-client/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/Examples/simple-fcm-client/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
index cde69bcccec65160d92116f20ffce4fce0b5245c..4b230716fda96981b99cd9b5f9e05c0b7a707275 100644
Binary files a/Examples/simple-fcm-client/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/Examples/simple-fcm-client/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/Examples/simple-fcm-client/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/Examples/simple-fcm-client/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
index c133a0cbd379f5af6dbf1a899a0293ca5eccfad0..999313723d83457179b58d6799f5d32e65551736 100644
Binary files a/Examples/simple-fcm-client/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/Examples/simple-fcm-client/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/Examples/simple-fcm-client/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/Examples/simple-fcm-client/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
index bfa42f0e7b91d006d22352c9ff2f134e504e3c1d..152373e58df2557540383a84b03eff3581af9e85 100644
Binary files a/Examples/simple-fcm-client/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/Examples/simple-fcm-client/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/Examples/simple-fcm-client/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/Examples/simple-fcm-client/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..2f2e6d57a0c8bfa1633d676702c7db6869f5ae62 100644
Binary files a/Examples/simple-fcm-client/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/Examples/simple-fcm-client/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/Examples/simple-fcm-client/app/App.js b/Examples/simple-fcm-client/app/App.js
index a23d555849d0fdf743c69917e9dd0e5bde4dd9fd..b3066bb5b3f945e484237dcf7c78396a6124f023 100644
--- a/Examples/simple-fcm-client/app/App.js
+++ b/Examples/simple-fcm-client/app/App.js
@@ -47,6 +47,10 @@ export default class App extends Component {
firebaseClient.sendData(token)} style={styles.button}>
Send Data
+
+ firebaseClient.sendNotificationWithData(token)} style={styles.button}>
+ Send Notification With Data
+
);
}
@@ -73,7 +77,7 @@ const styles = StyleSheet.create({
backgroundColor: "teal",
paddingHorizontal: 20,
paddingVertical: 10,
- marginVertical: 5,
+ marginVertical: 15,
borderRadius: 10
},
buttonText: {
diff --git a/Examples/simple-fcm-client/app/FirebaseClient.js b/Examples/simple-fcm-client/app/FirebaseClient.js
index 1f13297a5b2c8fe7eeada0733dc22d322fac6015..2c583b381773c9cfca4be5c02d0fa304c7f5c339 100644
--- a/Examples/simple-fcm-client/app/FirebaseClient.js
+++ b/Examples/simple-fcm-client/app/FirebaseClient.js
@@ -7,19 +7,18 @@ class FirebaseClient {
constructor() {
this.sendData = this.sendData.bind(this);
this.sendNotification = this.sendNotification.bind(this);
+ this.sendNotificationWithData = this.sendNotificationWithData.bind(this);
}
sendNotification(token) {
let body = {
"to": token,
- "notification":{
- "icon": "appLogo",
- "title": "Notification Title",
- "body": "Notification Body",
+ "notification":{
+ "title": "Simple FCM Client",
+ "body": "This is a notification with only NOTIFICATION.",
"sound": "default",
"click_action": "fcm.ACTION.HELLO"
},
- "content_available": true,
"priority": 10
}
@@ -30,19 +29,39 @@ class FirebaseClient {
let body = {
"to": token,
"data":{
- "icon": "appLogo",
- "title": "Notification Title",
- "body": "Notification Body",
+ "title": "Simple FCM Client",
+ "body": "This is a notification with only DATA.",
"sound": "default",
- "click_action": "fcm.ACTION.HELLO"
+ "click_action": "fcm.ACTION.HELLO",
+ "remote": true
},
- "content_available": true,
- "priority": 10
+ "priority": "normal"
}
this._send(JSON.stringify(body), "data");
}
+ sendNotificationWithData(token) {
+ let body = {
+ "to": token,
+ "notification":{
+ "title": "Simple FCM Client",
+ "body": "This is a notification with NOTIFICATION and DATA (NOTIF).",
+ "sound": "default",
+ "click_action": "fcm.ACTION.HELLO"
+ },
+ "data":{
+ "title": "Simple FCM Client",
+ "body": "This is a notification with NOTIFICATION and DATA (DATA)",
+ "click_action": "fcm.ACTION.HELLO",
+ "remote": true
+ },
+ "priority": "high"
+ }
+
+ this._send(JSON.stringify(body), "notification-data");
+ }
+
_send(body, type) {
let headers = new Headers({
"Content-Type": "application/json",
diff --git a/Examples/simple-fcm-client/app/PushController.js b/Examples/simple-fcm-client/app/PushController.js
index c6ca152a0f6626d6cadb084f35963bddd8ad448a..e61d905c2e48cb1e80ff4568ce7b197f5a302b01 100644
--- a/Examples/simple-fcm-client/app/PushController.js
+++ b/Examples/simple-fcm-client/app/PushController.js
@@ -23,6 +23,10 @@ export default class PushController extends Component {
this.notificationUnsubscribe = FCM.on("notification", notif => {
console.log("Notification", notif);
+ if (notif && notif.local) {
+ return;
+ }
+ this.sendRemote(notif);
});
this.refreshUnsubscribe = FCM.on("refreshToken", token => {
@@ -31,6 +35,17 @@ export default class PushController extends Component {
});
}
+ sendRemote(notif) {
+ FCM.presentLocalNotification({
+ title: notif.title,
+ body: notif.body,
+ priority: "high",
+ click_action: notif.click_action,
+ show_in_foreground: true,
+ local: true
+ });
+ }
+
componentWillUnmount() {
this.refreshUnsubscribe();
this.notificationUnsubscribe();
diff --git a/Examples/simple-fcm-client/ios/SimpleFcmClient.xcodeproj/project.pbxproj b/Examples/simple-fcm-client/ios/SimpleFcmClient.xcodeproj/project.pbxproj
index fcb61c0039d86553bd113cbc7e7de15e564b80f7..c7c3a934280a06e268631ed9c5bca42cf08971eb 100644
--- a/Examples/simple-fcm-client/ios/SimpleFcmClient.xcodeproj/project.pbxproj
+++ b/Examples/simple-fcm-client/ios/SimpleFcmClient.xcodeproj/project.pbxproj
@@ -30,7 +30,7 @@
4339BFDD1DAEBA7300F53B62 /* GoogleUtilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4339BFD71DAEBA7300F53B62 /* GoogleUtilities.framework */; };
4339BFE01DAEBA7F00F53B62 /* FirebaseMessaging.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4339BFDE1DAEBA7F00F53B62 /* FirebaseMessaging.framework */; };
4339BFE11DAEBA7F00F53B62 /* GoogleIPhoneUtilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4339BFDF1DAEBA7F00F53B62 /* GoogleIPhoneUtilities.framework */; };
- 4339BFE51DAED44A00F53B62 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4339BFE41DAED44A00F53B62 /* GoogleService-Info.plist */; };
+ 4339BFE81DAEE9D100F53B62 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4339BFE71DAEE9D100F53B62 /* GoogleService-Info.plist */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
FAE94A218EB64E38BF8D8E9B /* libRNFIRMessaging.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 692E216422234A4CB6A7A838 /* libRNFIRMessaging.a */; };
/* End PBXBuildFile section */
@@ -152,8 +152,8 @@
4339BFDF1DAEBA7F00F53B62 /* GoogleIPhoneUtilities.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = GoogleIPhoneUtilities.framework; sourceTree = ""; };
4339BFE21DAEBB3500F53B62 /* Firebase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Firebase.h; sourceTree = ""; };
4339BFE31DAEBB4800F53B62 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = ""; };
- 4339BFE41DAED44A00F53B62 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; };
4339BFE61DAED4D900F53B62 /* SimpleFcmClient.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = SimpleFcmClient.entitlements; path = SimpleFcmClient/SimpleFcmClient.entitlements; sourceTree = ""; };
+ 4339BFE71DAEE9D100F53B62 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; };
692E216422234A4CB6A7A838 /* libRNFIRMessaging.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNFIRMessaging.a; sourceTree = ""; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; };
@@ -274,8 +274,8 @@
13B07FAE1A68108700A75B9A /* SimpleFcmClient */ = {
isa = PBXGroup;
children = (
+ 4339BFE71DAEE9D100F53B62 /* GoogleService-Info.plist */,
4339BFE61DAED4D900F53B62 /* SimpleFcmClient.entitlements */,
- 4339BFE41DAED44A00F53B62 /* GoogleService-Info.plist */,
4339BFE31DAEBB4800F53B62 /* module.modulemap */,
4339BFE21DAEBB3500F53B62 /* Firebase.h */,
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
@@ -600,9 +600,9 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 4339BFE51DAED44A00F53B62 /* GoogleService-Info.plist in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
+ 4339BFE81DAEE9D100F53B62 /* GoogleService-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};