Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 18 additions & 19 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
---
name: ⚠️ Bug/Issue report
about: Please provide as much detail as possible to help us with a bug or issue. Issues
name: ⚠️ Bug/Issue report
about: Please provide as much detail as possible to help us with a bug or issue. Issues
will be closed if they do not follow the template.

---

<!---
BEFORE YOU MAKE AN ISSUE
The issue list of this repo is exclusively for bug reports.
1) For feature requests, please use our Canny board: https://react-native-firebase.canny.io/feature-requests
2) For questions and support please use our Discord chat: https://discord.gg/C9aK28N or Stack Overflow: https://stackoverflow.com/questions/tagged/react-native-firebase
3) If this is a setup issue then please make sure you've correctly followed the setup guides, most setup issues such as 'duplicate dex files', 'default app has not been initialized' etc are all down to an incorrect setup as the guides haven't been correctly followed.
<!---
BEFORE YOU MAKE AN ISSUE

The issue list of this repo is exclusively for bug reports.

1) For feature requests, please use our Canny board: https://react-native-firebase.canny.io/feature-requests

2) For questions and support please use our Discord chat: https://discord.gg/C9aK28N or Stack Overflow: https://stackoverflow.com/questions/tagged/react-native-firebase

3) If this is a setup issue then please make sure you've correctly followed the setup guides, most setup issues such as 'duplicate dex files', 'default app has not been initialized' etc are all down to an incorrect setup as the guides haven't been correctly followed.
-->

### Issue
Expand All @@ -23,7 +22,7 @@ The issue list of this repo is exclusively for bug reports.

### Environment

1. Application Target Platform:
1. Application Target Platform:

<!--- (e.g. iOS, Android, Both) --->

Expand All @@ -47,14 +46,14 @@ The issue list of this repo is exclusively for bug reports.

<!--- (e.g. database, auth, messaging, analytics etc - or N/A if not applicable) --->

7. Are you using `typescript`?
7. Are you using `typescript`?

<!--- yes/no --->


---

Loving `react-native-firebase`? Please consider supporting them with any of the below:

- 👉 Back financially via [Open Collective](https://opencollective.com/react-native-firebase/donate)
- 👉 Follow [`React Native Firebase`](https://twitter.com/rnfirebase) and [`Invertase`](https://twitter.com/invertaseio) on Twitter
- 👉 Star this repo on GitHub ⭐️
* 👉 Back financially via [Open Collective](https://opencollective.com/react-native-firebase/donate)
* 👉 Follow [`React Native Firebase`](https://twitter.com/rnfirebase) and [`Invertase`](https://twitter.com/invertaseio) on Twitter
* 👉 Star this repo on GitHub ⭐️
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ All in all, RNFirebase provides much faster performance (~2x) over the web SDK a
| **Crashlytics**           | ❌ | ✅ | ✅ | ❌ |
| **Crash Reporting** | ✅ | ✅ | ✅ | ❌ |
| **Dynamic Links** | ❌ | ✅ | ✅ | ❌ |
| **[Functions Callable](https://firebase.googleblog.com/2018/04/launching-cloud-functions-for-firebase-1-0.html?m=1)**             |   ❌   |   ❌   | ✅ |   ✅   |
| **[Functions Callable](https://firebase.googleblog.com/2018/04/launching-cloud-functions-for-firebase-1-0.html?m=1)**             |   ❌   |   ❌   | ✅ |   ✅   |
| **Invites** | ❌ | ❌ | ✅ | ❌ |
| **Instance ID**          | ❌ | ❌ | **?** | ❌ |
| **Performance Monitoring** | ✅ | ✅ | ✅ | ❌ |
Expand All @@ -64,11 +64,11 @@ All in all, RNFirebase provides much faster performance (~2x) over the web SDK a

> The table below shows the supported versions of React Native and the Firebase SDKs for different versions of `react-native-firebase`.

| | 2.2.x | 3.3.x | 4.0.x | 4.1.x | 4.2.x |
| -------------------- | -------- | -------- | -------- | -------- | -------- |
| React Native | 0.47 + | 0.50 + | 0.52 + | 0.52 + | 0.52-55.x |
| Firebase Android SDK | 11.0.0 + | 11.8.0 + | 12.0.0 + | 15.0.0 + | 15.0.0 + |
| Firebase iOS SDK | 4.0.0 + | 4.7.0 + | 4.11.0 + | 4.13.0 + | 5.0.0 + |
| | 2.2.x | 3.3.x | 4.0.x | 4.1.x | 4.2.x |
| -------------------- | -------- | -------- | -------- | -------- | --------- |
| React Native | 0.47 + | 0.50 + | 0.52 + | 0.52 + | 0.52-55.x |
| Firebase Android SDK | 11.0.0 + | 11.8.0 + | 12.0.0 + | 15.0.0 + | 15.0.0 + |
| Firebase iOS SDK | 4.0.0 + | 4.7.0 + | 4.11.0 + | 4.13.0 + | 5.0.0 + |

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,18 @@ protected Void doInBackground(Void... voids) {
}
}

String tag = null;
if (android.containsKey("tag")) {
tag = android.getString("tag");
}

// Create the notification intent
PendingIntent contentIntent = createIntent(intentClass, notification, android.getString("clickAction"));
nb = nb.setContentIntent(contentIntent);

// Build the notification and send it
Notification builtNotification = nb.build();
notificationManager.notify(notificationId.hashCode(), builtNotification);
notificationManager.notify(tag, notificationId.hashCode(), builtNotification);

if (reactContext != null) {
Utils.sendEvent(reactContext, "notifications_notification_displayed", Arguments.fromBundle(notification));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.RemoteInput;
Expand Down Expand Up @@ -153,7 +154,7 @@ public void displayScheduledNotification(Bundle notification) {
if (!notification.getBundle("schedule").containsKey("repeated")
|| !notification.getBundle("schedule").getBoolean("repeated")) {
String notificationId = notification.getString("notificationId");
preferences.edit().remove(notificationId).apply();;
preferences.edit().remove(notificationId).apply();
}

if (Utils.isAppInForeground(context)) {
Expand Down Expand Up @@ -195,6 +196,15 @@ public void removeDeliveredNotification(String notificationId, Promise promise)
promise.resolve(null);
}

public void removeDeliveredNotificationsByTag(String tag, Promise promise) {
StatusBarNotification[] statusBarNotifications = notificationManager.getActiveNotifications();
for (StatusBarNotification statusBarNotification : statusBarNotifications) {
if (statusBarNotification.getTag() == tag) {
notificationManager.cancel(statusBarNotification.getTag(), statusBarNotification.getId());
}
}
promise.resolve(null);
}

public void rescheduleNotifications() {
ArrayList<Bundle> bundles = getScheduledNotifications();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public void removeDeliveredNotification(String notificationId, Promise promise)
notificationManager.removeDeliveredNotification(notificationId, promise);
}

@ReactMethod
public void removeDeliveredNotificationsByTag(String tag, Promise promise) {
notificationManager.removeDeliveredNotificationsByTag(tag, promise);
}

@ReactMethod
public void setBadge(int badge, Promise promise) {
// Store the badge count for later retrieval
Expand Down Expand Up @@ -296,6 +301,7 @@ private WritableMap parseRemoteMessage(RemoteMessage message) {
}
if (notification.getTag() != null) {
androidMap.putString("group", notification.getTag());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have the tag property, I don't think we should also set that as the group as they are two separate things. Are you able to remove the group?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the group could be a breaking change for some people, because of that I'm not sure if we should do that.

androidMap.putString("tag", notification.getTag());
}
notificationMap.putMap("android", androidMap);

Expand Down
6 changes: 3 additions & 3 deletions ios/RNFirebase/notifications/RNFirebaseNotifications.m
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
resolve(nil);
});
}

RCT_EXPORT_METHOD(jsInitialised:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
jsReady = TRUE;
resolve(nil);
Expand Down Expand Up @@ -487,11 +487,11 @@ - (UNNotificationRequest*) buildUNNotificationRequest:(NSDictionary *) notificat
NSString *identifier = a[@"identifier"];
NSURL *url = [NSURL fileURLWithPath:a[@"url"]];
NSMutableDictionary *attachmentOptions = nil;

if (a[@"options"]) {
NSDictionary *options = a[@"options"];
attachmentOptions = [[NSMutableDictionary alloc] init];

for (id key in options) {
if ([key isEqualToString:@"typeHint"]) {
attachmentOptions[UNNotificationAttachmentOptionsTypeHintKey] = options[key];
Expand Down
2 changes: 2 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,7 @@ declare module 'react-native-firebase' {
showWhen?: boolean;
smallIcon?: any;
sortKey?: string;
tag?: string;
ticker?: string;
timeoutAfter?: number;
usesChronometer?: boolean;
Expand Down Expand Up @@ -1265,6 +1266,7 @@ declare module 'react-native-firebase' {
setShowWhen(showWhen: boolean): Notification;
setSmallIcon(icon: string, level?: number): Notification;
setSortKey(sortKey: string): Notification;
setTag(tag: string): Notification;
setTicker(ticker: string): Notification;
setTimeoutAfter(timeoutAfter: number): Notification;
setUsesChronometer(usesChronometer: boolean): Notification;
Expand Down
17 changes: 17 additions & 0 deletions lib/modules/notifications/AndroidNotification.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default class AndroidNotification {
_smallIcon: SmallIcon;
_sortKey: string | void;
// TODO: style: Style; // Need to figure out if this can work
_tag: string | void;
_ticker: string | void;
_timeoutAfter: number | void;
_usesChronometer: boolean | void;
Expand Down Expand Up @@ -106,6 +107,7 @@ export default class AndroidNotification {
this._showWhen = data.showWhen;
this._smallIcon = data.smallIcon;
this._sortKey = data.sortKey;
this._tag = data.tag;
this._ticker = data.ticker;
this._timeoutAfter = data.timeoutAfter;
this._usesChronometer = data.usesChronometer;
Expand Down Expand Up @@ -238,6 +240,10 @@ export default class AndroidNotification {
return this._sortKey;
}

get tag(): ?string {
return this._tag;
}

get ticker(): ?string {
return this._ticker;
}
Expand Down Expand Up @@ -615,6 +621,16 @@ export default class AndroidNotification {
return this._notification;
}

/**
*
* @param tag
* @returns {Notification}
*/
setTag(tag: string): Notification {
this._tag = tag;
return this._notification;
}

/**
*
* @param ticker
Expand Down Expand Up @@ -719,6 +735,7 @@ export default class AndroidNotification {
smallIcon: this._smallIcon,
sortKey: this._sortKey,
// TODO: style: Style,
tag: this._tag,
ticker: this._ticker,
timeoutAfter: this._timeoutAfter,
usesChronometer: this._usesChronometer,
Expand Down
22 changes: 16 additions & 6 deletions lib/modules/notifications/AndroidNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,28 @@ export default class AndroidNotifications {
return Promise.resolve();
}

removeDeliveredNotificationsByTag(tag: string): Promise<void> {
if (Platform.OS === 'android') {
if (typeof tag !== 'string') {
throw new Error(
`AndroidNotifications:removeDeliveredNotificationsByTag expects an 'string' but got type ${typeof tag}`
);
}
return getNativeModule(
this._notifications
).removeDeliveredNotificationsByTag(tag);
}
return Promise.resolve();
}

deleteChannelGroup(groupId: string): Promise<void> {
if (Platform.OS === 'android') {
if (typeof groupId !== 'string') {
throw new Error(
`AndroidNotifications:deleteChannelGroup expects an 'string' but got type ${typeof groupId}`
);
}
return getNativeModule(this._notifications).deleteChannelGroup(
groupId
);
return getNativeModule(this._notifications).deleteChannelGroup(groupId);
}
return Promise.resolve();
}
Expand All @@ -113,9 +125,7 @@ export default class AndroidNotifications {
`AndroidNotifications:deleteChannel expects an 'string' but got type ${typeof channelId}`
);
}
return getNativeModule(this._notifications).deleteChannel(
channelId
);
return getNativeModule(this._notifications).deleteChannel(channelId);
}
return Promise.resolve();
}
Expand Down
1 change: 1 addition & 0 deletions lib/modules/notifications/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export type NativeAndroidNotification = {|
smallIcon: SmallIcon,
sortKey?: string,
// TODO: style: Style,
tag?: string,
ticker?: string,
timeoutAfter?: number,
usesChronometer?: boolean,
Expand Down