[ios] add backwards compatibility to RN imports - fixed #80
This commit is contained in:
parent
8b8077cf4d
commit
da556ae8c9
|
@ -2,9 +2,21 @@
|
|||
#define RNFirebase_h
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "RCTBridgeModule.h"
|
||||
#if __has_include(<React/RCTEventDispatcher.h>)
|
||||
#import <React/RCTEventDispatcher.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTEventDispatcher.h"
|
||||
#endif
|
||||
#if __has_include(<React/RCTEventEmitter.h>)
|
||||
#import <React/RCTEventEmitter.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTEventEmitter.h"
|
||||
#endif
|
||||
#if __has_include(<React/RCTBridgeModule.h>)
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTBridgeModule.h"
|
||||
#endif
|
||||
|
||||
@interface RNFirebase : RCTEventEmitter <RCTBridgeModule> {
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
#ifndef RNFirebaseAnalytics_h
|
||||
#define RNFirebaseAnalytics_h
|
||||
|
||||
#if __has_include(<React/RCTBridgeModule.h>)
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTBridgeModule.h"
|
||||
#endif
|
||||
|
||||
@interface RNFirebaseAnalytics : NSObject <RCTBridgeModule> {
|
||||
|
||||
|
|
|
@ -2,8 +2,16 @@
|
|||
#define RNFirebaseAuth_h
|
||||
|
||||
#import "Firebase.h"
|
||||
#if __has_include(<React/RCTEventEmitter.h>)
|
||||
#import <React/RCTEventEmitter.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTEventEmitter.h"
|
||||
#endif
|
||||
#if __has_include(<React/RCTBridgeModule.h>)
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTBridgeModule.h"
|
||||
#endif
|
||||
|
||||
@interface RNFirebaseAuth : RCTEventEmitter <RCTBridgeModule> {
|
||||
FIRAuthStateDidChangeListenerHandle authListenerHandle;
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
#ifndef RNFirebaseCrash_h
|
||||
#define RNFirebaseCrash_h
|
||||
|
||||
#if __has_include(<React/RCTBridgeModule.h>)
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTBridgeModule.h"
|
||||
#endif
|
||||
|
||||
@interface RNFirebaseCrash : NSObject <RCTBridgeModule> {
|
||||
|
||||
|
|
|
@ -2,8 +2,16 @@
|
|||
#define RNFirebaseDatabase_h
|
||||
|
||||
#import "Firebase.h"
|
||||
#if __has_include(<React/RCTEventEmitter.h>)
|
||||
#import <React/RCTEventEmitter.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTEventEmitter.h"
|
||||
#endif
|
||||
#if __has_include(<React/RCTBridgeModule.h>)
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTBridgeModule.h"
|
||||
#endif
|
||||
|
||||
@interface RNFirebaseDatabase : RCTEventEmitter <RCTBridgeModule> {
|
||||
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
#ifndef RNFirebaseErrors_h
|
||||
#define RNFirebaseErrors_h
|
||||
|
||||
#if __has_include(<React/RCTBridgeModule.h>)
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTBridgeModule.h"
|
||||
#endif
|
||||
#import "Firebase.h"
|
||||
|
||||
@interface RNFirebaseErrors : NSObject <RCTBridgeModule> {
|
||||
|
|
|
@ -5,9 +5,22 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "Firebase.h"
|
||||
|
||||
#if __has_include(<React/RCTEventEmitter.h>)
|
||||
#import <React/RCTEventEmitter.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTEventEmitter.h"
|
||||
#endif
|
||||
#if __has_include(<React/RCTBridgeModule.h>)
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTBridgeModule.h"
|
||||
#endif
|
||||
#if __has_include(<React/RCTUtils.h>)
|
||||
#import <React/RCTUtils.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTUtils.h"
|
||||
#endif
|
||||
|
||||
@import UserNotifications;
|
||||
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
#import "RNFirebaseMessaging.h"
|
||||
|
||||
#import <React/RCTConvert.h>
|
||||
#if __has_include(<React/RCTEventDispatcher.h>)
|
||||
#import <React/RCTEventDispatcher.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTEventDispatcher.h"
|
||||
#endif
|
||||
#if __has_include(<React/RCTConvert.h>)
|
||||
#import <React/RCTConvert.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTConvert.h"
|
||||
#endif
|
||||
#if __has_include(<React/RCTUtils.h>)
|
||||
#import <React/RCTUtils.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTUtils.h"
|
||||
#endif
|
||||
|
||||
@import UserNotifications;
|
||||
#import <FirebaseMessaging/FirebaseMessaging.h>
|
||||
|
@ -53,13 +65,13 @@ RCT_ENUM_CONVERTER(NSCalendarUnit,
|
|||
content.categoryIdentifier = [RCTConvert NSString:details[@"click_action"]];
|
||||
content.userInfo = details;
|
||||
content.badge = [RCTConvert NSNumber:details[@"badge"]];
|
||||
|
||||
|
||||
NSDate *fireDate = [RCTConvert NSDate:details[@"fire_date"]];
|
||||
|
||||
|
||||
if(fireDate == nil){
|
||||
return [UNNotificationRequest requestWithIdentifier:[RCTConvert NSString:details[@"id"]] content:content trigger:nil];
|
||||
}
|
||||
|
||||
|
||||
NSCalendarUnit interval = [RCTConvert NSCalendarUnit:details[@"repeat_interval"]];
|
||||
NSCalendarUnit unitFlags;
|
||||
switch (interval) {
|
||||
|
@ -177,12 +189,12 @@ RCT_EXPORT_MODULE()
|
|||
- (void)setBridge:(RCTBridge *)bridge
|
||||
{
|
||||
_bridge = bridge;
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleNotificationReceived:)
|
||||
name:FCMNotificationReceived
|
||||
object:nil];
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(disconnectFCM)
|
||||
name:UIApplicationDidEnterBackgroundNotification
|
||||
|
@ -191,19 +203,19 @@ RCT_EXPORT_MODULE()
|
|||
selector:@selector(connectToFCM)
|
||||
name:UIApplicationDidBecomeActiveNotification
|
||||
object:nil];
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self selector:@selector(onTokenRefresh)
|
||||
name:kFIRInstanceIDTokenRefreshNotification object:nil];
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self selector:@selector(sendDataMessageFailure:)
|
||||
name:FIRMessagingSendErrorNotification object:nil];
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self selector:@selector(sendDataMessageSuccess:)
|
||||
name:FIRMessagingSendSuccessNotification object:nil];
|
||||
|
||||
|
||||
// For iOS 10 data message (sent via FCM)
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[FIRMessaging messaging] setRemoteMessageDelegate:self];
|
||||
|
@ -283,7 +295,7 @@ RCT_EXPORT_METHOD(requestPermissions:(RCTPromiseResolveBlock)resolve rejecter:(R
|
|||
];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
[[UIApplication sharedApplication] registerForRemoteNotifications];
|
||||
}
|
||||
|
||||
|
@ -459,22 +471,22 @@ RCT_EXPORT_METHOD(finishNotificationResponse: (NSString *)completionHandlerId){
|
|||
self.notificationCallbacks[completionHandlerId] = completionHandler;
|
||||
data[@"_completionHandlerId"] = completionHandlerId;
|
||||
}
|
||||
|
||||
|
||||
[_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:data];
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)sendDataMessageFailure:(NSNotification *)notification
|
||||
{
|
||||
NSString *messageID = (NSString *)notification.userInfo[@"messageID"];
|
||||
|
||||
|
||||
NSLog(@"sendDataMessageFailure: %@", messageID);
|
||||
}
|
||||
|
||||
- (void)sendDataMessageSuccess:(NSNotification *)notification
|
||||
{
|
||||
NSString *messageID = (NSString *)notification.userInfo[@"messageID"];
|
||||
|
||||
|
||||
NSLog(@"sendDataMessageSuccess: %@", messageID);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,16 @@
|
|||
#define RNFirebaseStorage_h
|
||||
|
||||
#import "Firebase.h"
|
||||
#import "RCTBridgeModule.h"
|
||||
#if __has_include(<React/RCTEventEmitter.h>)
|
||||
#import <React/RCTEventEmitter.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTEventEmitter.h"
|
||||
#endif
|
||||
#if __has_include(<React/RCTBridgeModule.h>)
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#else // Compatibility for RN version < 0.40
|
||||
#import "RCTBridgeModule.h"
|
||||
#endif
|
||||
|
||||
@interface RNFirebaseStorage : RCTEventEmitter <RCTBridgeModule> {
|
||||
|
||||
|
|
Loading…
Reference in New Issue