Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-fcm
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ym
react-native-fcm
Commits
bdcdcd1f
Commit
bdcdcd1f
authored
Feb 12, 2018
by
Libin Lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update example with action
parent
05d33533
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
24 deletions
+80
-24
Examples/simple-fcm-client/app/App.js
Examples/simple-fcm-client/app/App.js
+12
-19
Examples/simple-fcm-client/app/Listeners.js
Examples/simple-fcm-client/app/Listeners.js
+23
-5
Examples/simple-fcm-client/ios/SimpleFcmClient.xcodeproj/project.pbxproj
...-fcm-client/ios/SimpleFcmClient.xcodeproj/project.pbxproj
+45
-0
No files found.
Examples/simple-fcm-client/app/App.js
View file @
bdcdcd1f
...
...
@@ -134,21 +134,14 @@ export default class App extends Component {
firebaseClient
.
send
(
JSON
.
stringify
(
body
),
"
data
"
);
}
sendRemoteNotificationWithData
(
token
)
{
let
body
=
{
"
to
"
:
token
,
"
notification
"
:{
"
title
"
:
"
Simple FCM Client
"
,
"
body
"
:
"
This is a notification with NOTIFICATION and DATA (NOTIF).
"
,
"
sound
"
:
"
default
"
},
"
data
"
:{
"
hello
"
:
"
there
"
},
"
priority
"
:
"
high
"
}
firebaseClient
.
send
(
JSON
.
stringify
(
body
),
"
notification-data
"
);
showLocalNotificationWithAction
()
{
FCM
.
presentLocalNotification
({
title
:
'
Test Notification with action
'
,
body
:
'
Force touch to reply
'
,
priority
:
"
high
"
,
show_in_foreground
:
true
,
click_action
:
"
com.myidentifi.fcm.text
"
});
}
render
()
{
...
...
@@ -185,12 +178,12 @@ export default class App extends Component {
<Text style={styles.buttonText}>Send Remote Data</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.s
endRemoteNotificationWithData(token
)} style={styles.button}>
<Text style={styles.buttonText}>S
end Remote Notification With Data
</Text>
<TouchableOpacity onPress={() => this.s
howLocalNotification(
)} style={styles.button}>
<Text style={styles.buttonText}>S
how Local Notification
</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.showLocalNotification
(
)} style={styles.button}>
<Text style={styles.buttonText}>S
end Local Notifica
tion</Text>
<TouchableOpacity onPress={() => this.showLocalNotification
WithAction(token
)} style={styles.button}>
<Text style={styles.buttonText}>S
how Local Notification with Ac
tion</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.scheduleLocalNotification()} style={styles.button}>
...
...
Examples/simple-fcm-client/app/Listeners.js
View file @
bdcdcd1f
import
{
Platform
,
AsyncStorage
}
from
'
react-native
'
;
import
FCM
,
{
FCMEvent
,
RemoteNotificationResult
,
WillPresentNotificationResult
,
NotificationType
}
from
"
react-native-fcm
"
;
import
FCM
,
{
FCMEvent
,
RemoteNotificationResult
,
WillPresentNotificationResult
,
NotificationType
,
NotificationActionType
,
NotificationActionOption
,
NotificationCategoryOption
}
from
"
react-native-fcm
"
;
AsyncStorage
.
getItem
(
'
lastNotification
'
).
then
(
data
=>
{
if
(
data
){
...
...
@@ -21,11 +21,11 @@ export function registerKilledListener(){
export
function
registerAppListener
(){
FCM
.
on
(
FCMEvent
.
Notification
,
notif
=>
{
console
.
log
(
"
Notification
"
,
notif
);
if
(
notif
.
local_notification
){
return
;
}
if
(
notif
.
opened_from_tray
){
return
;
if
(
notif
.
_actionIdentifier
===
'
com.myidentifi.fcm.text.reply
'
){
alert
(
"
User replied:
"
+
notif
.
_userText
);
}
}
if
(
Platform
.
OS
===
'
ios
'
){
...
...
@@ -61,3 +61,21 @@ export function registerAppListener(){
FCM
.
isDirectChannelEstablished
().
then
(
d
=>
console
.
log
(
d
));
},
1000
);
}
FCM
.
setNotificationCategories
([
{
id
:
'
com.myidentifi.fcm.text
'
,
actions
:
[
{
type
:
NotificationActionType
.
TextInput
,
id
:
'
com.myidentifi.fcm.text.reply
'
,
title
:
'
Reply
'
,
textInputButtonTitle
:
'
Send
'
,
textInputPlaceholder
:
'
Say something
'
,
intentIdentifiers
:
[],
options
:
NotificationActionOption
.
AuthenticationRequired
}
],
options
:
[
NotificationCategoryOption
.
CustomDismissAction
,
NotificationCategoryOption
.
PreviewsShowTitle
]
}
])
Examples/simple-fcm-client/ios/SimpleFcmClient.xcodeproj/project.pbxproj
View file @
bdcdcd1f
...
...
@@ -23,6 +23,7 @@
140ED2AC1D01E1AD002B40FF
/* libReact.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
146834041AC3E56700842450
/* libReact.a */
;
};
146834051AC3E58100842450
/* libReact.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
146834041AC3E56700842450
/* libReact.a */
;
};
3A6D62911E2044AB00D0D2C7
/* libz.tbd in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3A6D62901E2044AB00D0D2C7
/* libz.tbd */
;
};
3A7531B520323B2400888478
/* libRCTAnimation.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3A7531B220323B0700888478
/* libRCTAnimation.a */
;
};
3AC87E631F6C190900194883
/* bell.mp3 in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3AC87E621F6C190900194883
/* bell.mp3 */
;
};
4339BFE81DAEE9D100F53B62
/* GoogleService-Info.plist in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
4339BFE71DAEE9D100F53B62
/* GoogleService-Info.plist */
;
};
5FE70723D2AE04BF2D98342D
/* libPods-SimpleFcmClientTests.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0E8C044191FA88F1BCCF08BD
/* libPods-SimpleFcmClientTests.a */
;
};
...
...
@@ -186,6 +187,20 @@
remoteGlobalIDString
=
3D3CD9181DE5FBD800167DC4
;
remoteInfo
=
"jschelpers-tvOS"
;
};
3A7531B120323B0700888478
/* PBXContainerItemProxy */
=
{
isa
=
PBXContainerItemProxy
;
containerPortal
=
3A7531AC20323B0700888478
/* RCTAnimation.xcodeproj */
;
proxyType
=
2
;
remoteGlobalIDString
=
134814201AA4EA6300B7C361
;
remoteInfo
=
RCTAnimation
;
};
3A7531B320323B0700888478
/* PBXContainerItemProxy */
=
{
isa
=
PBXContainerItemProxy
;
containerPortal
=
3A7531AC20323B0700888478
/* RCTAnimation.xcodeproj */
;
proxyType
=
2
;
remoteGlobalIDString
=
2D2A28201D9B03D100D4039D
;
remoteInfo
=
"RCTAnimation-tvOS"
;
};
3AAE7F501F55B50200E914A8
/* PBXContainerItemProxy */
=
{
isa
=
PBXContainerItemProxy
;
containerPortal
=
146833FF1AC3E56700842450
/* React.xcodeproj */
;
...
...
@@ -260,6 +275,7 @@
146833FF1AC3E56700842450
/* React.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
React.xcodeproj
;
path
=
"../node_modules/react-native/React/React.xcodeproj"
;
sourceTree
=
"<group>"
;
};
3A6D628E1E20449400D0D2C7
/* libc++.tbd */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"sourcecode.text-based-dylib-definition"
;
name
=
"libc++.tbd"
;
path
=
"usr/lib/libc++.tbd"
;
sourceTree
=
SDKROOT
;
};
3A6D62901E2044AB00D0D2C7
/* libz.tbd */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"sourcecode.text-based-dylib-definition"
;
name
=
libz.tbd
;
path
=
usr/lib/libz.tbd
;
sourceTree
=
SDKROOT
;
};
3A7531AC20323B0700888478
/* RCTAnimation.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
RCTAnimation.xcodeproj
;
path
=
"../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"
;
sourceTree
=
"<group>"
;
};
3AC87E621F6C190900194883
/* bell.mp3 */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
audio.mp3
;
path
=
bell.mp3
;
sourceTree
=
"<group>"
;
};
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>"
;
};
...
...
@@ -289,6 +305,7 @@
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
3A7531B520323B2400888478
/* libRCTAnimation.a in Frameworks */
,
3A6D62911E2044AB00D0D2C7
/* libz.tbd in Frameworks */
,
146834051AC3E58100842450
/* libReact.a in Frameworks */
,
00C302E51ABCBA2D00DB3ED1
/* libRCTActionSheet.a in Frameworks */
,
...
...
@@ -422,6 +439,15 @@
name
=
Products
;
sourceTree
=
"<group>"
;
};
3A7531AD20323B0700888478
/* Products */
=
{
isa
=
PBXGroup
;
children
=
(
3A7531B220323B0700888478
/* libRCTAnimation.a */
,
3A7531B420323B0700888478
/* libRCTAnimation.a */
,
);
name
=
Products
;
sourceTree
=
"<group>"
;
};
3AF0A6071F7BE4DC004B899F
/* Recovered References */
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -472,6 +498,7 @@
832341AE1AAA6A7D00B99B32
/* Libraries */
=
{
isa
=
PBXGroup
;
children
=
(
3A7531AC20323B0700888478
/* RCTAnimation.xcodeproj */
,
146833FF1AC3E56700842450
/* React.xcodeproj */
,
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
,
00C302B51ABCB90400DB3ED1
/* RCTGeolocation.xcodeproj */
,
...
...
@@ -609,6 +636,10 @@
ProductGroup
=
00C302A81ABCB8CE00DB3ED1
/* Products */
;
ProjectRef
=
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
;
},
{
ProductGroup
=
3A7531AD20323B0700888478
/* Products */
;
ProjectRef
=
3A7531AC20323B0700888478
/* RCTAnimation.xcodeproj */
;
},
{
ProductGroup
=
00C302B61ABCB90400DB3ED1
/* Products */
;
ProjectRef
=
00C302B51ABCB90400DB3ED1
/* RCTGeolocation.xcodeproj */
;
...
...
@@ -806,6 +837,20 @@
remoteRef
=
3A6D627D1E20428000D0D2C7
/* PBXContainerItemProxy */
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
3A7531B220323B0700888478
/* libRCTAnimation.a */
=
{
isa
=
PBXReferenceProxy
;
fileType
=
archive.ar
;
path
=
libRCTAnimation.a
;
remoteRef
=
3A7531B120323B0700888478
/* PBXContainerItemProxy */
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
3A7531B420323B0700888478
/* libRCTAnimation.a */
=
{
isa
=
PBXReferenceProxy
;
fileType
=
archive.ar
;
path
=
libRCTAnimation.a
;
remoteRef
=
3A7531B320323B0700888478
/* PBXContainerItemProxy */
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
3AAE7F511F55B50200E914A8
/* libthird-party.a */
=
{
isa
=
PBXReferenceProxy
;
fileType
=
archive.ar
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment