Commit 60d941f6 authored by Libin Lu's avatar Libin Lu

remove warning

parent 9296ffc4
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <FirebaseCore/FIRApp.h> #import <FirebaseCore/FIRApp.h>
#import <FirebaseMessaging/FirebaseMessaging.h>
#import <React/RCTBridgeModule.h> #import <React/RCTEventEmitter.h>
@import UserNotifications; @import UserNotifications;
@interface RNFIRMessaging : NSObject <RCTBridgeModule> @interface RNFIRMessaging : RCTEventEmitter <RCTBridgeModule, FIRMessagingDelegate>
typedef void (^RCTRemoteNotificationCallback)(UIBackgroundFetchResult result); typedef void (^RCTRemoteNotificationCallback)(UIBackgroundFetchResult result);
typedef void (^RCTWillPresentNotificationCallback)(UNNotificationPresentationOptions result); typedef void (^RCTWillPresentNotificationCallback)(UNNotificationPresentationOptions result);
......
#import "RNFIRMessaging.h" #import "RNFIRMessaging.h"
#import <React/RCTConvert.h> #import <React/RCTConvert.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTUtils.h> #import <React/RCTUtils.h>
@import UserNotifications; @import UserNotifications;
#import <FirebaseMessaging/FirebaseMessaging.h>
#import <FirebaseInstanceID/FirebaseInstanceID.h> #import <FirebaseInstanceID/FirebaseInstanceID.h>
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0 #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0
...@@ -134,9 +132,8 @@ RCT_ENUM_CONVERTER(UNNotificationPresentationOptions, (@{ ...@@ -134,9 +132,8 @@ RCT_ENUM_CONVERTER(UNNotificationPresentationOptions, (@{
@implementation RNFIRMessaging @implementation RNFIRMessaging
RCT_EXPORT_MODULE()
@synthesize bridge = _bridge; @synthesize bridge = _bridge;
RCT_EXPORT_MODULE();
+ (void)didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull RCTRemoteNotificationCallback)completionHandler { + (void)didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull RCTRemoteNotificationCallback)completionHandler {
NSMutableDictionary* data = [[NSMutableDictionary alloc] initWithDictionary: userInfo]; NSMutableDictionary* data = [[NSMutableDictionary alloc] initWithDictionary: userInfo];
...@@ -228,7 +225,8 @@ RCT_EXPORT_MODULE() ...@@ -228,7 +225,8 @@ RCT_EXPORT_MODULE()
NSLog(@"Disconnected from FCM"); NSLog(@"Disconnected from FCM");
} }
RCT_EXPORT_METHOD(getInitialNotification:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject){ RCT_EXPORT_METHOD(getInitialNotification:(RCTPromiseResolveBlock)resolve)
{
UILocalNotification *localUserInfo = _bridge.launchOptions[UIApplicationLaunchOptionsLocalNotificationKey]; UILocalNotification *localUserInfo = _bridge.launchOptions[UIApplicationLaunchOptionsLocalNotificationKey];
if (localUserInfo) { if (localUserInfo) {
resolve([[localUserInfo userInfo] copy]); resolve([[localUserInfo userInfo] copy]);
...@@ -237,17 +235,17 @@ RCT_EXPORT_METHOD(getInitialNotification:(RCTPromiseResolveBlock)resolve rejecte ...@@ -237,17 +235,17 @@ RCT_EXPORT_METHOD(getInitialNotification:(RCTPromiseResolveBlock)resolve rejecte
resolve([_bridge.launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] copy]); resolve([_bridge.launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] copy]);
} }
RCT_EXPORT_METHOD(getFCMToken:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) RCT_EXPORT_METHOD(getFCMToken:(RCTPromiseResolveBlock)resolve)
{ {
resolve([[FIRInstanceID instanceID] token]); resolve([[FIRInstanceID instanceID] token]);
} }
- (void) onTokenRefresh - (void) onTokenRefresh
{ {
[_bridge.eventDispatcher sendDeviceEventWithName:@"FCMTokenRefreshed" body:[[FIRInstanceID instanceID] token]]; [self sendEventWithName:@"FCMTokenRefreshed" body:[[FIRInstanceID instanceID] token]];
} }
RCT_EXPORT_METHOD(requestPermissions) RCT_EXPORT_METHOD(requestPermissions:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{ {
if (RCTRunningInAppExtension()) { if (RCTRunningInAppExtension()) {
return; return;
...@@ -261,9 +259,6 @@ RCT_EXPORT_METHOD(requestPermissions) ...@@ -261,9 +259,6 @@ RCT_EXPORT_METHOD(requestPermissions)
UIUserNotificationSettings *notificationSettings = UIUserNotificationSettings *notificationSettings =
[UIUserNotificationSettings settingsForTypes:(NSUInteger)allNotificationTypes categories:nil]; [UIUserNotificationSettings settingsForTypes:(NSUInteger)allNotificationTypes categories:nil];
[app registerUserNotificationSettings:notificationSettings]; [app registerUserNotificationSettings:notificationSettings];
} else {
//iOS 7 or below
[app registerForRemoteNotificationTypes:(NSUInteger)allNotificationTypes];
} }
} else { } else {
// iOS 10 or later // iOS 10 or later
...@@ -275,6 +270,11 @@ RCT_EXPORT_METHOD(requestPermissions) ...@@ -275,6 +270,11 @@ RCT_EXPORT_METHOD(requestPermissions)
[[UNUserNotificationCenter currentNotificationCenter] [[UNUserNotificationCenter currentNotificationCenter]
requestAuthorizationWithOptions:authOptions requestAuthorizationWithOptions:authOptions
completionHandler:^(BOOL granted, NSError * _Nullable error) { completionHandler:^(BOOL granted, NSError * _Nullable error) {
if(granted){
resolve(nil);
} else{
reject(@"notification_error", @"Failed to grand permission", error);
}
} }
]; ];
#endif #endif
...@@ -295,7 +295,7 @@ RCT_EXPORT_METHOD(unsubscribeFromTopic: (NSString*) topic) ...@@ -295,7 +295,7 @@ RCT_EXPORT_METHOD(unsubscribeFromTopic: (NSString*) topic)
// Receive data message on iOS 10 devices. // Receive data message on iOS 10 devices.
- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage { - (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
[_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:[remoteMessage appData]]; [self sendEventWithName:FCMNotificationReceived body:[remoteMessage appData]];
} }
RCT_EXPORT_METHOD(presentLocalNotification:(id)data resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) RCT_EXPORT_METHOD(presentLocalNotification:(id)data resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
...@@ -373,14 +373,13 @@ RCT_EXPORT_METHOD(cancelLocalNotification:(NSString*) notificationId) ...@@ -373,14 +373,13 @@ RCT_EXPORT_METHOD(cancelLocalNotification:(NSString*) notificationId)
} }
} }
RCT_EXPORT_METHOD(getScheduledLocalNotifications:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) RCT_EXPORT_METHOD(getScheduledLocalNotifications:(RCTPromiseResolveBlock)resolve)
{ {
if([UNUserNotificationCenter currentNotificationCenter] != nil){ if([UNUserNotificationCenter currentNotificationCenter] != nil){
[[UNUserNotificationCenter currentNotificationCenter] getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> * _Nonnull requests) { [[UNUserNotificationCenter currentNotificationCenter] getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> * _Nonnull requests) {
NSMutableArray* list = [[NSMutableArray alloc] init]; NSMutableArray* list = [[NSMutableArray alloc] init];
for(UNNotificationRequest * notif in requests){ for(UNNotificationRequest * notif in requests){
NSString* interval; UNNotificationContent *content = notif.content;
UNMutableNotificationContent *content = notif.content;
[list addObject:content.userInfo]; [list addObject:content.userInfo];
} }
resolve(list); resolve(list);
...@@ -396,10 +395,10 @@ RCT_EXPORT_METHOD(getScheduledLocalNotifications:(RCTPromiseResolveBlock)resolve ...@@ -396,10 +395,10 @@ RCT_EXPORT_METHOD(getScheduledLocalNotifications:(RCTPromiseResolveBlock)resolve
RCT_EXPORT_METHOD(setBadgeNumber: (NSInteger*) number) RCT_EXPORT_METHOD(setBadgeNumber: (NSInteger*) number)
{ {
[RCTSharedApplication() setApplicationIconBadgeNumber:number]; [RCTSharedApplication() setApplicationIconBadgeNumber:*number];
} }
RCT_EXPORT_METHOD(getBadgeNumber: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) RCT_EXPORT_METHOD(getBadgeNumber: (RCTPromiseResolveBlock)resolve)
{ {
resolve(@([RCTSharedApplication() applicationIconBadgeNumber])); resolve(@([RCTSharedApplication() applicationIconBadgeNumber]));
} }
...@@ -467,7 +466,7 @@ RCT_EXPORT_METHOD(finishNotificationResponse: (NSString *)completionHandlerId){ ...@@ -467,7 +466,7 @@ RCT_EXPORT_METHOD(finishNotificationResponse: (NSString *)completionHandlerId){
data[@"_completionHandlerId"] = completionHandlerId; data[@"_completionHandlerId"] = completionHandlerId;
} }
[_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:data]; [self sendEventWithName:FCMNotificationReceived body:data];
} }
......
...@@ -153,13 +153,14 @@ ...@@ -153,13 +153,14 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
WARNING_CFLAGS = ( WARNING_CFLAGS = (
"-Wextra", "-Wextra",
"-Wall", "-Wall",
"-Wno-semicolon-before-method-body",
); );
}; };
name = Debug; name = Debug;
...@@ -194,13 +195,14 @@ ...@@ -194,13 +195,14 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
WARNING_CFLAGS = ( WARNING_CFLAGS = (
"-Wextra", "-Wextra",
"-Wall", "-Wall",
"-Wno-semicolon-before-method-body",
); );
}; };
name = Release; name = Release;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment