Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-fcm
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ym
react-native-fcm
Commits
60d941f6
Commit
60d941f6
authored
Jun 03, 2017
by
Libin Lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove warning
parent
9296ffc4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
22 deletions
+24
-22
ios/RNFIRMessaging.h
ios/RNFIRMessaging.h
+3
-2
ios/RNFIRMessaging.m
ios/RNFIRMessaging.m
+17
-18
ios/RNFIRMessaging.xcodeproj/project.pbxproj
ios/RNFIRMessaging.xcodeproj/project.pbxproj
+4
-2
No files found.
ios/RNFIRMessaging.h
View file @
60d941f6
...
...
@@ -2,12 +2,13 @@
#import <UIKit/UIKit.h>
#import <FirebaseCore/FIRApp.h>
#import <FirebaseMessaging/FirebaseMessaging.h>
#import <React/RCT
BridgeModule
.h>
#import <React/RCT
EventEmitter
.h>
@import
UserNotifications
;
@interface
RNFIRMessaging
:
NSObject
<
RCTBridgeModul
e
>
@interface
RNFIRMessaging
:
RCTEventEmitter
<
RCTBridgeModule
,
FIRMessagingDelegat
e
>
typedef
void
(
^
RCTRemoteNotificationCallback
)(
UIBackgroundFetchResult
result
);
typedef
void
(
^
RCTWillPresentNotificationCallback
)(
UNNotificationPresentationOptions
result
);
...
...
ios/RNFIRMessaging.m
View file @
60d941f6
#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
sendDevice
EventWithName
:
@"FCMTokenRefreshed"
body
:[[
FIRInstanceID
instanceID
]
token
]];
[
self
send
EventWithName
:
@"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
sendDevice
EventWithName
:
FCMNotificationReceived
body
:[
remoteMessage
appData
]];
[
self
send
EventWithName
:
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
sendDevice
EventWithName
:
FCMNotificationReceived
body
:
data
];
[
self
send
EventWithName
:
FCMNotificationReceived
body
:
data
];
}
...
...
ios/RNFIRMessaging.xcodeproj/project.pbxproj
View file @
60d941f6
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment