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