[ios] Add hasPermission method
This commit is contained in:
parent
93805062f7
commit
b5b02ed84d
@ -212,6 +212,19 @@ RCT_EXPORT_METHOD(getInitialMessage:(RCTPromiseResolveBlock)resolve rejecter:(RC
|
||||
resolve(nil);
|
||||
}
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(hasPermission: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
||||
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
|
||||
resolve(@([RCTSharedApplication() currentUserNotificationSettings].types != UIUserNotificationTypeNone));
|
||||
} else {
|
||||
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
|
||||
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
|
||||
resolve(@(settings.alertSetting == UNNotificationSettingEnabled));
|
||||
}];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RCT_EXPORT_METHOD(sendMessage: (NSDictionary *) message
|
||||
resolve:(RCTPromiseResolveBlock) resolve
|
||||
|
@ -13,28 +13,29 @@ import type App from '../core/firebase-app';
|
||||
|
||||
type Notification = {
|
||||
body: string,
|
||||
bodyLocalizationArgs: string[],
|
||||
bodyLocalizationKey: string,
|
||||
clickAction: string,
|
||||
color: string,
|
||||
icon: string,
|
||||
link: string,
|
||||
bodyLocalizationArgs?: string[],
|
||||
bodyLocalizationKey?: string,
|
||||
clickAction?: string,
|
||||
color?: string,
|
||||
icon?: string,
|
||||
link?: string,
|
||||
sound: string,
|
||||
tag: string,
|
||||
subtitle?: string,
|
||||
tag?: string,
|
||||
title: string,
|
||||
titleLocalizationArgs: string[],
|
||||
titleLocalizationKey: string,
|
||||
titleLocalizationArgs?: string[],
|
||||
titleLocalizationKey?: string,
|
||||
};
|
||||
|
||||
type Message = {
|
||||
collapseKey: string,
|
||||
collapseKey?: string,
|
||||
data: { [string]: string },
|
||||
from: string,
|
||||
from?: string,
|
||||
messageId: string,
|
||||
messageType?: string,
|
||||
openedFromTray: boolean,
|
||||
notification?: Notification,
|
||||
sentTime: number,
|
||||
sentTime?: number,
|
||||
to?: string,
|
||||
ttl?: number,
|
||||
};
|
||||
@ -54,7 +55,7 @@ type OnTokenRefreshObserver = {
|
||||
type RemoteMessage = {
|
||||
collapseKey?: string,
|
||||
data: { [string]: string },
|
||||
messageId?: string,
|
||||
messageId: string,
|
||||
messageType?: string,
|
||||
to: string,
|
||||
ttl: number,
|
||||
@ -164,6 +165,10 @@ export default class Messaging extends ModuleBase {
|
||||
return getNativeModule(this).getInitialMessage();
|
||||
}
|
||||
|
||||
hasPermission(): Promise<boolean> {
|
||||
return getNativeModule(this).hasPermission();
|
||||
}
|
||||
|
||||
sendMessage(remoteMessage: RemoteMessage): Promise<void> {
|
||||
return getNativeModule(this).send(remoteMessage);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user