Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(messaging,ios): keep original UNUserNotificationCenter delegate #3427

Merged
merged 9 commits into from
Apr 22, 2020
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
]
}
},
"version": "6.4.0"
"version": "6.4.1-alpha.0"
}
2 changes: 1 addition & 1 deletion packages/admob/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/admob",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - Google AdMob is an easy way to monetize mobile apps with targeted, in-app advertising.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/analytics",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - The analytics module provides out of the box support with Google Analytics for Firebase. Integration with the Android & iOS allows for in-depth analytical insight reporting, such as device information, location, user actions and more.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/app-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/app-types",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "@react-native-firebase/app-types",
"files": [
Expand Down
4 changes: 2 additions & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/app",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Functions, Messaging (FCM), Remote Config, Storage and more.",
"main": "lib/index.js",
Expand Down Expand Up @@ -53,7 +53,7 @@
"react-native": "*"
},
"dependencies": {
"@react-native-firebase/app-types": "6.4.0",
"@react-native-firebase/app-types": "^6.4.1-alpha.0",
"opencollective-postinstall": "^2.0.1",
"superstruct": "^0.6.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/auth",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - The authentication module provides an easy-to-use API to integrate an authentication workflow into new and existing applications. React Native Firebase provides access to all Firebase authentication methods and identity providers.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/crashlytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/crashlytics",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - Firebase Crashlytics is a lightweight, realtime crash reporter that helps you track, prioritize, and fix stability issues that erode your app quality. React Native Firebase provides automatic crash reporting for both native and JavaScript errors, including unhandled promise rejections.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/database/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/database",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. React Native Firebase provides native integration with the Android & iOS Firebase SDKs, supporting both realtime data sync and offline capabilities.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/dynamic-links/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/dynamic-links",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - Dynamic Links",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/firestore",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - Cloud Firestore is a NoSQL cloud database to store and sync data between your React Native application and Firebase's database. The API matches the Firebase Web SDK whilst taking advantage of the native SDKs performance and offline capabilities.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/functions",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. React Native Firebase supports integration with production and locally emulated Cloud Functions with a simple API interface.\n\n",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/iid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/iid",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - Firebase Instance ID provides a unique identifier for each instance of your app and a mechanism to authenticate and authorize actions for it (for example: sending FCM messages).",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/in-app-messaging/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/in-app-messaging",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - Firebase In-App Messaging helps you engage your app's active users by sending them targeted, contextual messages that encourage them to use key app features. React Native Firebase provides support for both native Android & iOS integration with a simple JavaScript API.",
"main": "lib/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ NS_ASSUME_NONNULL_BEGIN

@interface RNFBMessagingUNUserNotificationCenter : NSObject <UNUserNotificationCenterDelegate>

@property NSDictionary* initialNotification;
@property NSDictionary *initialNotification;
@property(nonatomic, nullable, weak) id <UNUserNotificationCenterDelegate> originalDelegate;

+ (_Nonnull instancetype)sharedInstance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
#import "RNFBMessaging+UNUserNotificationCenter.h"

@implementation RNFBMessagingUNUserNotificationCenter
struct {
unsigned int willPresentNotification:1;
unsigned int didReceiveNotificationResponse:1;
unsigned int openSettingsForNotification:1;
} originalDelegateRespondsTo;

+ (instancetype)sharedInstance {
static dispatch_once_t once;
Expand All @@ -38,6 +43,12 @@ - (void)observe {
dispatch_once(&once, ^{
RNFBMessagingUNUserNotificationCenter *strongSelf = weakSelf;
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
if (center.delegate != nil) {
_originalDelegate = center.delegate;
originalDelegateRespondsTo.openSettingsForNotification = (unsigned int) [_originalDelegate respondsToSelector:@selector(userNotificationCenter:openSettingsForNotification:)];
originalDelegateRespondsTo.willPresentNotification = (unsigned int) [_originalDelegate respondsToSelector:@selector(userNotificationCenter:willPresentNotification:withCompletionHandler:)];
originalDelegateRespondsTo.didReceiveNotificationResponse = (unsigned int) [_originalDelegate respondsToSelector:@selector(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)];
}
center.delegate = strongSelf;
});
}
Expand All @@ -64,6 +75,10 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNot

// TODO in a later version allow customising completion options in JS code
completionHandler(UNNotificationPresentationOptionNone);
} else if (_originalDelegate != nil && originalDelegateRespondsTo.willPresentNotification) {
[_originalDelegate userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler];
} else {
completionHandler(UNNotificationPresentationOptionNone);
}
}

Expand All @@ -74,6 +89,16 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNoti
[[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_notification_opened" body:notificationDict];
_initialNotification = notificationDict;
completionHandler();
} else if (_originalDelegate != nil && originalDelegateRespondsTo.didReceiveNotificationResponse) {
[_originalDelegate userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
} else {
completionHandler();
}
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(nullable UNNotification *)notification {
if (_originalDelegate != nil && originalDelegateRespondsTo.openSettingsForNotification) {
[_originalDelegate userNotificationCenter:center openSettingsForNotification:notification];
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/messaging/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/messaging",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - React Native Firebase provides native integration of Firebase Cloud Messaging (FCM) for both Android & iOS. FCM is a cost free service, allowing for server-device and device-device communication. The React Native Firebase Messaging module provides a simple JavaScript API to interact with FCM.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/ml-natural-language/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/ml-natural-language",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - Firebase ML Kit brings the power of machine learning to your React Native application, supporting both Android & iOS.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/ml-vision/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/ml-vision",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - Firebase ML Kit brings the power of machine learning vision to your React Native application, supporting both Android & iOS.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/perf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/perf",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - React Native Firebase provides native integration with Performance Monitoring to gain insight into key performance characteristics within your React Native application.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/remote-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/remote-config",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - React Native Firebase provides native integration with Remote Config, allowing you to change the appearance and/or functionality of your app without requiring an app update.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/storage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/storage",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - React Native Firebase provides native integration with Cloud Storage, providing support to upload and download files directly from your device and from your Firebase Cloud Storage bucket.",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/template/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-firebase/template",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"author": "Invertase <[email protected]> (http://invertase.io)",
"description": "React Native Firebase - Template",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/template/project/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "HelloWorld",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"private": true,
"scripts": {
"start": "react-native start",
Expand All @@ -11,7 +11,7 @@
"prepare": "patch-package"
},
"dependencies": {
"@react-native-firebase/app": "6.4.0",
"@react-native-firebase/app": "^6.4.1-alpha.0",
"react": "16.9.0",
"react-native": "0.61.5"
},
Expand Down
38 changes: 19 additions & 19 deletions tests/package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"name": "react-native-firebase-tests",
"version": "6.4.0",
"version": "6.4.1-alpha.0",
"private": true,
"scripts": {
"build:clean": "rimraf dist && rimraf android/build && rimraf android/app/build && rimraf android/.gradle && rimraf ios/build",
"prepare": "patch-package"
},
"dependencies": {
"@react-native-firebase/admob": "6.4.0",
"@react-native-firebase/analytics": "6.4.0",
"@react-native-firebase/app": "6.4.0",
"@react-native-firebase/app-types": "6.4.0",
"@react-native-firebase/auth": "6.4.0",
"@react-native-firebase/crashlytics": "6.4.0",
"@react-native-firebase/database": "6.4.0",
"@react-native-firebase/dynamic-links": "6.4.0",
"@react-native-firebase/firestore": "6.4.0",
"@react-native-firebase/functions": "6.4.0",
"@react-native-firebase/iid": "6.4.0",
"@react-native-firebase/in-app-messaging": "6.4.0",
"@react-native-firebase/messaging": "6.4.0",
"@react-native-firebase/ml-natural-language": "6.4.0",
"@react-native-firebase/ml-vision": "6.4.0",
"@react-native-firebase/perf": "6.4.0",
"@react-native-firebase/remote-config": "6.4.0",
"@react-native-firebase/storage": "6.4.0",
"@react-native-firebase/admob": "^6.4.1-alpha.0",
"@react-native-firebase/analytics": "^6.4.1-alpha.0",
"@react-native-firebase/app": "^6.4.1-alpha.0",
"@react-native-firebase/app-types": "^6.4.1-alpha.0",
"@react-native-firebase/auth": "^6.4.1-alpha.0",
"@react-native-firebase/crashlytics": "^6.4.1-alpha.0",
"@react-native-firebase/database": "^6.4.1-alpha.0",
"@react-native-firebase/dynamic-links": "^6.4.1-alpha.0",
"@react-native-firebase/firestore": "^6.4.1-alpha.0",
"@react-native-firebase/functions": "^6.4.1-alpha.0",
"@react-native-firebase/iid": "^6.4.1-alpha.0",
"@react-native-firebase/in-app-messaging": "^6.4.1-alpha.0",
"@react-native-firebase/messaging": "^6.4.1-alpha.0",
"@react-native-firebase/ml-natural-language": "^6.4.1-alpha.0",
"@react-native-firebase/ml-vision": "^6.4.1-alpha.0",
"@react-native-firebase/perf": "^6.4.1-alpha.0",
"@react-native-firebase/remote-config": "^6.4.1-alpha.0",
"@react-native-firebase/storage": "^6.4.1-alpha.0",
"react": "16.8.6",
"react-native": "0.60.5"
},
Expand Down