Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
dc1cba2
changes
renzosal Aug 28, 2016
8890ec4
changes
renzosal Aug 28, 2016
1b57f8b
changes
renzosal Aug 28, 2016
6e00605
changes
renzosal Aug 28, 2016
2909c0c
scheduled notification
renzosal Aug 28, 2016
8e15ba3
fix
renzosal Aug 28, 2016
f0f1151
fixed
renzosal Aug 29, 2016
bad5ae7
change class name
renzosal Aug 29, 2016
fee42e1
add repeat
renzosal Aug 29, 2016
c265a8e
repeat every fix
renzosal Aug 29, 2016
9722021
refactor interval
renzosal Aug 29, 2016
689a868
fix
renzosal Aug 29, 2016
2221751
nullable long
renzosal Aug 29, 2016
b3455d2
check for null
renzosal Aug 29, 2016
311b064
cancel All notifications
renzosal Aug 29, 2016
50247e1
ios
renzosal Aug 29, 2016
b950b80
event listener
renzosal Aug 29, 2016
cd62eec
fix getTime
renzosal Aug 29, 2016
148a8b5
cancel Alarms
renzosal Aug 29, 2016
7ebcb7e
add editor
renzosal Aug 29, 2016
b1be05d
fix
renzosal Aug 29, 2016
56f41d8
fix
renzosal Aug 29, 2016
c0879da
java.util.map
renzosal Aug 29, 2016
75e4de7
added priority
renzosal Aug 30, 2016
6ac3d7e
added cancel notification
renzosal Aug 30, 2016
8d2fc63
fix
renzosal Aug 30, 2016
04b6d84
added Integer
renzosal Aug 30, 2016
4f2f731
typo change
renzosal Aug 30, 2016
3f213be
change
renzosal Aug 30, 2016
2cbfce9
handling id
renzosal Aug 30, 2016
2674b77
added readme
renzosal Aug 30, 2016
74c23d9
updated readme
renzosal Aug 30, 2016
2274ee0
README.md update
renzosal Aug 30, 2016
ed7c308
Merge pull request #1 from renzosal/notifications
renzosal Aug 30, 2016
a541beb
local notification fixes
renzosal Sep 11, 2016
dd73aa6
update readme
renzosal Sep 11, 2016
73145a7
Merge pull request #2 from renzosal/notifications2
renzosal Sep 11, 2016
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
63 changes: 60 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
+ <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
+ </intent-filter>
+ </service>

+ <receiver android:name="com.evollu.react.fcm.FIRLocalMessagingPublisher" />
...
```

Expand Down Expand Up @@ -131,6 +131,7 @@ Edit `AppDelegate.m`:
```diff
+ #import "Firebase.h" // if you are using Non Cocoapod approach
+ #import "RNFIRMessaging.h"
+ #import "RCTPushNotificationManager.h"
//...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Expand All @@ -143,6 +144,12 @@ Edit `AppDelegate.m`:
+ [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification];
+ handler(UIBackgroundFetchResultNewData);
+ }

+// Required for the localNotification event.
+- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
+{
+ [RCTPushNotificationManager didReceiveLocalNotification:notification];
+}
```

### FCM config file
Expand All @@ -164,6 +171,9 @@ class App extends Component {
this.notificationUnsubscribe = FCM.on('notification', (notif) => {
// there are two parts of notif. notif.notification contains the notification payload, notif.data contains data payload
});
this.localNotificationUnsubscribe = FCM.on('localNotification', (notif) => {
// notif.notification contains the data
});
this.refreshUnsubscribe = FCM.on('refreshToken', (token) => {
console.log(token)
// fcm token may not be available on first load, catch it here
Expand All @@ -177,6 +187,7 @@ class App extends Component {
// prevent leaking
this.refreshUnsubscribe();
this.notificationUnsubscribe();
this.localNotificationUnsubscribe();
}
}
```
Expand Down Expand Up @@ -211,15 +222,15 @@ class App extends Component {
```

and event callback will receive as:

- Android
```json
{
"fcm": {"action": "fcm.ACTION.HELLO"},
"extra": "juice"
}
```

- iOS
```json
{
Expand All @@ -233,6 +244,52 @@ class App extends Component {

NOTE: it is recommend not to rely on `data` payload for click_action as it can be overwritten (check [this](http://stackoverflow.com/questions/33738848/handle-multiple-notifications-with-gcm)).


### Local Notifications (still in progress)
Based on react-native-push-notification by zo0r and Neson

```javascript

//support for priority on android
const pushNotification = {
/* Android Only Properties */
priority: "high", //(optional) default: low, other options: 'min', 'max', 'high'
title: "My Notification Title", // (optional)
ticker: "My Notification Ticker", // (optional)
autoCancel: true, // (optional) default: true
largeIcon: "ic_launcher", // (optional) default: "ic_launcher"
smallIcon: "ic_notification", // (optional) default: "ic_notification" with fallback for "ic_launcher"
bigText: "My big text that will be shown when notification is expanded", // (optional) default: "message" prop
subText: "This is a subText", // (optional) default: none
color: "red", // (optional) default: system default
vibrate: true, // (optional) default: true
vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000
tag: 'some_tag', // (optional) add tag to message
group: "group", // (optional) add group to message
type:'my_custom_field_value', //custom field
/* iOS and Android properties */
id: 1234, // (optional)
message: "My Notification Message", // (required)
playSound: false, // (optional) default: true
number: 10 // (optional) default: none (Cannot be zero)
};

FCM.presentLocalNotification(pushNotification)

const pushNotification = {
//...
repeatEvery: "week"// other options: minute, hour, day, week
//...
}
FCM.scheduleLocalNotification(pushNotification)

//Cancel all notifications(IOS and ANDROID)
FCM.cancelLocalNotifications()

//Cancel notification by id(IOS and ANDROID)
FCM.cancelLocalNotification(notificationID)
```

## Q & A

#### My Android build is failing
Expand Down
Binary file added android/.DS_Store
Binary file not shown.
Loading