Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
Libin Lu committed Mar 6, 2018
1 parent 3e0b4d7 commit 0c53f19
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 37 deletions.
15 changes: 11 additions & 4 deletions Examples/simple-fcm-client/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {

import { StackNavigator } from 'react-navigation';

import FCM from "react-native-fcm";
import FCM, {NotificationActionType} from "react-native-fcm";

import {registerKilledListener, registerAppListener} from "./Listeners";
import firebaseClient from "./FirebaseClient";
Expand All @@ -39,7 +39,7 @@ class MainPage extends Component {
this.setState({
initNotif: notif
})
if(notif.targetScreen === 'detail'){
if(notif && notif.targetScreen === 'detail'){
setTimeout(()=>{
this.props.navigation.navigate('Detail')
}, 500)
Expand Down Expand Up @@ -154,7 +154,14 @@ class MainPage extends Component {
body: 'Force touch to reply',
priority: "high",
show_in_foreground: true,
click_action: "com.myidentifi.fcm.text"
click_action: "com.myidentifi.fcm.text", // for ios
android_actions: JSON.stringify([{
id: "view",
title: 'view'
},{
id: "dismiss",
title: 'dismiss'
}]) // for android, take syntax similar to ios's. only buttons are supported
});
}

Expand Down Expand Up @@ -188,7 +195,7 @@ class MainPage extends Component {
</TouchableOpacity>

<TouchableOpacity onPress={() => this.showLocalNotificationWithAction(token)} style={styles.button}>
<Text style={styles.buttonText}>Show Local Notification with Action (iOS)</Text>
<Text style={styles.buttonText}>Show Local Notification with Action</Text>
</TouchableOpacity>

<TouchableOpacity onPress={() => this.scheduleLocalNotification()} style={styles.button}>
Expand Down
33 changes: 18 additions & 15 deletions Examples/simple-fcm-client/app/Listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@ export function registerKilledListener(){
FCM.on(FCMEvent.Notification, notif => {
AsyncStorage.setItem('lastNotification', JSON.stringify(notif));
if(notif.opened_from_tray){
if(notif._actionIdentifier === 'com.myidentifi.fcm.text.reply'){
if(AppState.currentState !== 'background'){
alert('User replied '+ JSON.stringify(notif._userText));
} else {
AsyncStorage.setItem('lastMessage', JSON.stringify(notif._userText));
setTimeout(()=>{
if(notif._actionIdentifier === 'reply'){
if(AppState.currentState !== 'background'){
console.log('User replied '+ JSON.stringify(notif._userText))
alert('User replied '+ JSON.stringify(notif._userText));
} else {
AsyncStorage.setItem('lastMessage', JSON.stringify(notif._userText));
}
}
}
if(notif._actionIdentifier === 'com.myidentifi.fcm.text.view'){
alert("User clicked View in App");
}
if(notif._actionIdentifier === 'com.myidentifi.fcm.text.dismiss'){
alert("User clicked Dismiss");
}
if(notif._actionIdentifier === 'view'){
alert("User clicked View in App");
}
if(notif._actionIdentifier === 'dismiss'){
alert("User clicked Dismiss");
}
}, 1000)
}
});
}
Expand Down Expand Up @@ -100,7 +103,7 @@ FCM.setNotificationCategories([
actions: [
{
type: NotificationActionType.TextInput,
id: 'com.myidentifi.fcm.text.reply',
id: 'reply',
title: 'Quick Reply',
textInputButtonTitle: 'Send',
textInputPlaceholder: 'Say something',
Expand All @@ -109,14 +112,14 @@ FCM.setNotificationCategories([
},
{
type: NotificationActionType.Default,
id: 'com.myidentifi.fcm.text.view',
id: 'view',
title: 'View in App',
intentIdentifiers: [],
options: NotificationActionOption.Foreground
},
{
type: NotificationActionType.Default,
id: 'com.myidentifi.fcm.text.dismiss',
id: 'dismiss',
title: 'Dismiss',
intentIdentifiers: [],
options: NotificationActionOption.Destructive
Expand Down
22 changes: 11 additions & 11 deletions Examples/simple-fcm-client/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
PODS:
- Firebase/Core (4.8.2):
- Firebase/Core (4.9.0):
- FirebaseAnalytics (= 4.0.9)
- FirebaseCore (= 4.0.14)
- Firebase/Messaging (4.8.2):
- FirebaseCore (= 4.0.15)
- Firebase/Messaging (4.9.0):
- Firebase/Core
- FirebaseMessaging (= 2.0.8)
- FirebaseMessaging (= 2.1.0)
- FirebaseAnalytics (4.0.9):
- FirebaseCore (~> 4.0)
- FirebaseInstanceID (~> 2.0)
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- nanopb (~> 0.3)
- FirebaseCore (4.0.14):
- FirebaseCore (4.0.15):
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- FirebaseInstanceID (2.0.8):
- FirebaseInstanceID (2.0.9):
- FirebaseCore (~> 4.0)
- FirebaseMessaging (2.0.8):
- FirebaseMessaging (2.1.0):
- FirebaseAnalytics (~> 4.0)
- FirebaseCore (~> 4.0)
- FirebaseInstanceID (~> 2.0)
Expand All @@ -36,11 +36,11 @@ DEPENDENCIES:
- Firebase/Messaging

SPEC CHECKSUMS:
Firebase: 7d3b8cd837ad9fcd391657734c0d56dab8e9a5a3
Firebase: 632216af3ed7f31e3be34776947fdc7546cfb572
FirebaseAnalytics: 388b630c15713f5dbf364071f5f3d6077fb52f4e
FirebaseCore: 2e0b98fb2d64ca8140136beff15772bdd14d2dd7
FirebaseInstanceID: 81df5805a08001e69138664bdd02c6719a9ac80f
FirebaseMessaging: dfdcd307c2382290a1e297a81d0f18370f5b1bcd
FirebaseCore: 3bd047463058fa6b5d312c97502c52e45401cdfb
FirebaseInstanceID: d2058a35e9bebda1b6dd42486b84917bde552a9d
FirebaseMessaging: 2bafab2d0f3ab3dfd753101c2c32995c2051b5da
GoogleToolboxForMac: 2501e2ad72a52eb3dfe7bd9aee7dad11b858bd20
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
};
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
Expand All @@ -28,8 +29,8 @@
5FE70723D2AE04BF2D98342D /* libPods-SimpleFcmClientTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E8C044191FA88F1BCCF08BD /* libPods-SimpleFcmClientTests.a */; };
6976C617E52062E3EE272128 /* libPods-SimpleFcmClient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A959965489E40CE19F2B06B4 /* libPods-SimpleFcmClient.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
FAE94A218EB64E38BF8D8E9B /* libRNFIRMessaging.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 692E216422234A4CB6A7A838 /* libRNFIRMessaging.a */; };
B5EEA6C40DAD43C696D4A7EE /* libAirMaps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 441E689027CF4924A5FEA8F6 /* libAirMaps.a */; };
FAE94A218EB64E38BF8D8E9B /* libRNFIRMessaging.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 692E216422234A4CB6A7A838 /* libRNFIRMessaging.a */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -201,6 +202,13 @@
remoteGlobalIDString = 2D2A28201D9B03D100D4039D;
remoteInfo = "RCTAnimation-tvOS";
};
3AA3D5D4204DD40F00C3E8E6 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 955F937AAFAB473EA79C80F7 /* AirMaps.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 11FA5C511C4A1296003AC2EE;
remoteInfo = AirMaps;
};
3AAE7F501F55B50200E914A8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
Expand Down Expand Up @@ -280,17 +288,17 @@
4339BFE31DAEBB4800F53B62 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
4339BFE61DAED4D900F53B62 /* SimpleFcmClient.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = SimpleFcmClient.entitlements; path = SimpleFcmClient/SimpleFcmClient.entitlements; sourceTree = "<group>"; };
4339BFE71DAEE9D100F53B62 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
441E689027CF4924A5FEA8F6 /* libAirMaps.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libAirMaps.a; sourceTree = "<group>"; };
55A6E80F734FA3F596B96C04 /* Pods-SimpleFcmClientTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SimpleFcmClientTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SimpleFcmClientTests/Pods-SimpleFcmClientTests.debug.xcconfig"; sourceTree = "<group>"; };
64204739CA77D9B1EB1F0788 /* Pods-SimpleFcmClientTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SimpleFcmClientTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-SimpleFcmClientTests/Pods-SimpleFcmClientTests.release.xcconfig"; sourceTree = "<group>"; };
692E216422234A4CB6A7A838 /* libRNFIRMessaging.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNFIRMessaging.a; sourceTree = "<group>"; };
73B4AFC1AC5C6373F8074CBC /* Pods-SimpleFcmClient.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SimpleFcmClient.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SimpleFcmClient/Pods-SimpleFcmClient.debug.xcconfig"; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
955F937AAFAB473EA79C80F7 /* AirMaps.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = AirMaps.xcodeproj; path = "../node_modules/react-native-maps/lib/ios/AirMaps.xcodeproj"; sourceTree = "<group>"; };
A959965489E40CE19F2B06B4 /* libPods-SimpleFcmClient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SimpleFcmClient.a"; sourceTree = BUILT_PRODUCTS_DIR; };
C7DEB70C413E484CBFA6AC45 /* RNFIRMessaging.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNFIRMessaging.xcodeproj; path = "../node_modules/react-native-fcm/ios/RNFIRMessaging.xcodeproj"; sourceTree = "<group>"; };
CF6939675D5A4A68FBE567C0 /* Pods-SimpleFcmClient.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SimpleFcmClient.release.xcconfig"; path = "Pods/Target Support Files/Pods-SimpleFcmClient/Pods-SimpleFcmClient.release.xcconfig"; sourceTree = "<group>"; };
955F937AAFAB473EA79C80F7 /* AirMaps.xcodeproj */ = {isa = PBXFileReference; name = "AirMaps.xcodeproj"; path = "../node_modules/react-native-maps/lib/ios/AirMaps.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
441E689027CF4924A5FEA8F6 /* libAirMaps.a */ = {isa = PBXFileReference; name = "libAirMaps.a"; path = "libAirMaps.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -451,10 +459,19 @@
name = Products;
sourceTree = "<group>";
};
3AA3D5D1204DD40F00C3E8E6 /* Products */ = {
isa = PBXGroup;
children = (
3AA3D5D5204DD40F00C3E8E6 /* libAirMaps.a */,
);
name = Products;
sourceTree = "<group>";
};
3AF0A6071F7BE4DC004B899F /* Recovered References */ = {
isa = PBXGroup;
children = (
692E216422234A4CB6A7A838 /* libRNFIRMessaging.a */,
441E689027CF4924A5FEA8F6 /* libAirMaps.a */,
);
name = "Recovered References";
sourceTree = "<group>";
Expand Down Expand Up @@ -636,6 +653,10 @@
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 3AA3D5D1204DD40F00C3E8E6 /* Products */;
ProjectRef = 955F937AAFAB473EA79C80F7 /* AirMaps.xcodeproj */;
},
{
ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */;
ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;
Expand Down Expand Up @@ -855,6 +876,13 @@
remoteRef = 3A7531B320323B0700888478 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
3AA3D5D5204DD40F00C3E8E6 /* libAirMaps.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libAirMaps.a;
remoteRef = 3AA3D5D4204DD40F00C3E8E6 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
3AAE7F511F55B50200E914A8 /* libthird-party.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
Expand Down
2 changes: 1 addition & 1 deletion Examples/simple-fcm-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"react": "16.0.0-alpha.12",
"react-native": "^0.47.2",
"react-native-fcm": "^14.0.1",
"react-native-fcm": "^14.1.0",
"react-native-maps": "^0.20.1",
"react-navigation": "^1.2.1"
},
Expand Down
6 changes: 3 additions & 3 deletions Examples/simple-fcm-client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3750,9 +3750,9 @@ react-native-drawer-layout@1.3.2:
dependencies:
react-native-dismiss-keyboard "1.0.0"

react-native-fcm@^14.0.1:
version "14.0.1"
resolved "https://registry.yarnpkg.com/react-native-fcm/-/react-native-fcm-14.0.1.tgz#833e6a38a1b2fd1a9b7b69be35e007f7361fe474"
react-native-fcm@^14.1.0:
version "14.1.0"
resolved "https://registry.yarnpkg.com/react-native-fcm/-/react-native-fcm-14.1.0.tgz#e1b58e041d4cc8bf100206a57bb5182d1324551c"

react-native-maps@^0.20.1:
version "0.20.1"
Expand Down

0 comments on commit 0c53f19

Please sign in to comment.