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

remove warning

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