Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
af4e247ef3
@ -7,6 +7,7 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
168785AD210B584E00E4BD57 /* RCTConvert+UIBackgroundFetchResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 168785AB210B584E00E4BD57 /* RCTConvert+UIBackgroundFetchResult.m */; };
|
||||||
17AF4F6B1F59CDBF00C02336 /* RNFirebaseLinks.m in Sources */ = {isa = PBXBuildFile; fileRef = 17AF4F6A1F59CDBF00C02336 /* RNFirebaseLinks.m */; };
|
17AF4F6B1F59CDBF00C02336 /* RNFirebaseLinks.m in Sources */ = {isa = PBXBuildFile; fileRef = 17AF4F6A1F59CDBF00C02336 /* RNFirebaseLinks.m */; };
|
||||||
27540F9A209F3641001F4AF4 /* RNFirebaseFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = 27540F99209F3641001F4AF4 /* RNFirebaseFunctions.m */; };
|
27540F9A209F3641001F4AF4 /* RNFirebaseFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = 27540F99209F3641001F4AF4 /* RNFirebaseFunctions.m */; };
|
||||||
8300A7AE1F31E143001B16AB /* RNFirebaseDatabaseReference.m in Sources */ = {isa = PBXBuildFile; fileRef = 8300A7AD1F31E143001B16AB /* RNFirebaseDatabaseReference.m */; };
|
8300A7AE1F31E143001B16AB /* RNFirebaseDatabaseReference.m in Sources */ = {isa = PBXBuildFile; fileRef = 8300A7AD1F31E143001B16AB /* RNFirebaseDatabaseReference.m */; };
|
||||||
@ -49,6 +50,8 @@
|
|||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
134814201AA4EA6300B7C361 /* libRNFirebase.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNFirebase.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
134814201AA4EA6300B7C361 /* libRNFirebase.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNFirebase.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
168785AB210B584E00E4BD57 /* RCTConvert+UIBackgroundFetchResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTConvert+UIBackgroundFetchResult.m"; sourceTree = "<group>"; };
|
||||||
|
168785AC210B584E00E4BD57 /* RCTConvert+UIBackgroundFetchResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTConvert+UIBackgroundFetchResult.h"; sourceTree = "<group>"; };
|
||||||
17AF4F691F59CDBF00C02336 /* RNFirebaseLinks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNFirebaseLinks.h; sourceTree = "<group>"; };
|
17AF4F691F59CDBF00C02336 /* RNFirebaseLinks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNFirebaseLinks.h; sourceTree = "<group>"; };
|
||||||
17AF4F6A1F59CDBF00C02336 /* RNFirebaseLinks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFirebaseLinks.m; sourceTree = "<group>"; };
|
17AF4F6A1F59CDBF00C02336 /* RNFirebaseLinks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFirebaseLinks.m; sourceTree = "<group>"; };
|
||||||
27540F98209F361B001F4AF4 /* RNFirebaseFunctions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNFirebaseFunctions.h; sourceTree = "<group>"; };
|
27540F98209F361B001F4AF4 /* RNFirebaseFunctions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNFirebaseFunctions.h; sourceTree = "<group>"; };
|
||||||
@ -123,6 +126,16 @@
|
|||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
168785A0210B50AA00E4BD57 /* converters */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
168785AC210B584E00E4BD57 /* RCTConvert+UIBackgroundFetchResult.h */,
|
||||||
|
168785AB210B584E00E4BD57 /* RCTConvert+UIBackgroundFetchResult.m */,
|
||||||
|
);
|
||||||
|
name = converters;
|
||||||
|
path = RNFirebase/converters;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
17AF4F681F59CDBF00C02336 /* links */ = {
|
17AF4F681F59CDBF00C02336 /* links */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -146,6 +159,7 @@
|
|||||||
58B511D21A9E6C8500147676 = {
|
58B511D21A9E6C8500147676 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
168785A0210B50AA00E4BD57 /* converters */,
|
||||||
27540F97209F35DF001F4AF4 /* functions */,
|
27540F97209F35DF001F4AF4 /* functions */,
|
||||||
83AAA0762063DEC2007EC5F7 /* invites */,
|
83AAA0762063DEC2007EC5F7 /* invites */,
|
||||||
838E372420231E15004DCD3A /* notifications */,
|
838E372420231E15004DCD3A /* notifications */,
|
||||||
@ -384,6 +398,7 @@
|
|||||||
27540F9A209F3641001F4AF4 /* RNFirebaseFunctions.m in Sources */,
|
27540F9A209F3641001F4AF4 /* RNFirebaseFunctions.m in Sources */,
|
||||||
838E372320231DF0004DCD3A /* RNFirebaseInstanceId.m in Sources */,
|
838E372320231DF0004DCD3A /* RNFirebaseInstanceId.m in Sources */,
|
||||||
839D916E1EF3E20B0077C7C8 /* RNFirebaseAdMobRewardedVideo.m in Sources */,
|
839D916E1EF3E20B0077C7C8 /* RNFirebaseAdMobRewardedVideo.m in Sources */,
|
||||||
|
168785AD210B584E00E4BD57 /* RCTConvert+UIBackgroundFetchResult.m in Sources */,
|
||||||
839D916C1EF3E20B0077C7C8 /* RNFirebaseAdMob.m in Sources */,
|
839D916C1EF3E20B0077C7C8 /* RNFirebaseAdMob.m in Sources */,
|
||||||
17AF4F6B1F59CDBF00C02336 /* RNFirebaseLinks.m in Sources */,
|
17AF4F6B1F59CDBF00C02336 /* RNFirebaseLinks.m in Sources */,
|
||||||
8376F7161F7C149100D45A85 /* RNFirebaseFirestoreCollectionReference.m in Sources */,
|
8376F7161F7C149100D45A85 /* RNFirebaseFirestoreCollectionReference.m in Sources */,
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
#import <React/RCTConvert.h>
|
||||||
|
|
||||||
|
@interface RCTConvert (UIBackgroundFetchResult)
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,9 @@
|
|||||||
|
#import "RCTConvert+UIBackgroundFetchResult.h"
|
||||||
|
|
||||||
|
@implementation RCTConvert (UIBackgroundFetchResult)
|
||||||
|
RCT_ENUM_CONVERTER(UIBackgroundFetchResult, (@{ @"backgroundFetchResultNoData" : @(UIBackgroundFetchResultNoData),
|
||||||
|
@"backgroundFetchResultNewData" : @(UIBackgroundFetchResultNewData),
|
||||||
|
@"backgroundFetchResultFailed" : @(UIBackgroundFetchResultFailed)}),
|
||||||
|
UIBackgroundFetchResultNoData, integerValue)
|
||||||
|
|
||||||
|
@end
|
@ -16,7 +16,9 @@
|
|||||||
#endif
|
#endif
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation RNFirebaseNotifications
|
@implementation RNFirebaseNotifications {
|
||||||
|
NSMutableDictionary<NSString *, void (^)(UIBackgroundFetchResult)> *completionHandlers;
|
||||||
|
}
|
||||||
|
|
||||||
static RNFirebaseNotifications *theRNFirebaseNotifications = nil;
|
static RNFirebaseNotifications *theRNFirebaseNotifications = nil;
|
||||||
// PRE-BRIDGE-EVENTS: Consider enabling this to allow events built up before the bridge is built to be sent to the JS side
|
// PRE-BRIDGE-EVENTS: Consider enabling this to allow events built up before the bridge is built to be sent to the JS side
|
||||||
@ -54,6 +56,7 @@ RCT_EXPORT_MODULE();
|
|||||||
|
|
||||||
// Set static instance for use from AppDelegate
|
// Set static instance for use from AppDelegate
|
||||||
theRNFirebaseNotifications = self;
|
theRNFirebaseNotifications = self;
|
||||||
|
completionHandlers = [[NSMutableDictionary alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
// PRE-BRIDGE-EVENTS: Consider enabling this to allow events built up before the bridge is built to be sent to the JS side
|
// PRE-BRIDGE-EVENTS: Consider enabling this to allow events built up before the bridge is built to be sent to the JS side
|
||||||
@ -95,6 +98,15 @@ RCT_EXPORT_MODULE();
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RCT_EXPORT_METHOD(complete:(NSString*)handlerKey fetchResult:(UIBackgroundFetchResult)fetchResult) {
|
||||||
|
void (^completionHandler)(UIBackgroundFetchResult) = completionHandlers[handlerKey];
|
||||||
|
completionHandlers[handlerKey] = nil;
|
||||||
|
|
||||||
|
if(completionHandler != nil) {
|
||||||
|
completionHandler(fetchResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Listen for background messages
|
// Listen for background messages
|
||||||
- (void)didReceiveRemoteNotification:(NSDictionary *)userInfo
|
- (void)didReceiveRemoteNotification:(NSDictionary *)userInfo
|
||||||
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
||||||
@ -106,6 +118,9 @@ RCT_EXPORT_MODULE();
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSDictionary *notification = [self parseUserInfo:userInfo];
|
||||||
|
NSString *handlerKey = notification[@"notificationId"];
|
||||||
|
|
||||||
NSString *event;
|
NSString *event;
|
||||||
if (RCTSharedApplication().applicationState == UIApplicationStateBackground) {
|
if (RCTSharedApplication().applicationState == UIApplicationStateBackground) {
|
||||||
event = NOTIFICATIONS_NOTIFICATION_DISPLAYED;
|
event = NOTIFICATIONS_NOTIFICATION_DISPLAYED;
|
||||||
@ -124,7 +139,6 @@ RCT_EXPORT_MODULE();
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSDictionary *notification = [self parseUserInfo:userInfo];
|
|
||||||
// For onOpened events, we set the default action name as iOS 8/9 has no concept of actions
|
// For onOpened events, we set the default action name as iOS 8/9 has no concept of actions
|
||||||
if (event == NOTIFICATIONS_NOTIFICATION_OPENED) {
|
if (event == NOTIFICATIONS_NOTIFICATION_OPENED) {
|
||||||
notification = @{
|
notification = @{
|
||||||
@ -133,8 +147,9 @@ RCT_EXPORT_MODULE();
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
completionHandlers[handlerKey] = completionHandler;
|
||||||
|
|
||||||
[self sendJSEvent:self name:event body:notification];
|
[self sendJSEvent:self name:event body:notification];
|
||||||
completionHandler(UIBackgroundFetchResultNoData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// *******************************************************
|
// *******************************************************
|
||||||
@ -226,7 +241,7 @@ RCT_EXPORT_METHOD(cancelNotification:(NSString*) notificationId
|
|||||||
if ([self isIOS89]) {
|
if ([self isIOS89]) {
|
||||||
for (UILocalNotification *notification in RCTSharedApplication().scheduledLocalNotifications) {
|
for (UILocalNotification *notification in RCTSharedApplication().scheduledLocalNotifications) {
|
||||||
NSDictionary *notificationInfo = notification.userInfo;
|
NSDictionary *notificationInfo = notification.userInfo;
|
||||||
if ([notificationId isEqualToString:[notificationInfo valueForKey:@"notificationId"]]) {
|
if ([notificationId isEqualToString:notificationInfo[@"notificationId"]]) {
|
||||||
[RCTSharedApplication() cancelLocalNotification:notification];
|
[RCTSharedApplication() cancelLocalNotification:notification];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -740,6 +755,12 @@ RCT_EXPORT_METHOD(jsInitialised:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
|||||||
return @[NOTIFICATIONS_NOTIFICATION_DISPLAYED, NOTIFICATIONS_NOTIFICATION_OPENED, NOTIFICATIONS_NOTIFICATION_RECEIVED];
|
return @[NOTIFICATIONS_NOTIFICATION_DISPLAYED, NOTIFICATIONS_NOTIFICATION_OPENED, NOTIFICATIONS_NOTIFICATION_RECEIVED];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *) constantsToExport {
|
||||||
|
return @{ @"backgroundFetchResultNoData" : @(UIBackgroundFetchResultNoData),
|
||||||
|
@"backgroundFetchResultNewData" : @(UIBackgroundFetchResultNewData),
|
||||||
|
@"backgroundFetchResultFailed" : @(UIBackgroundFetchResultFailed)};
|
||||||
|
}
|
||||||
|
|
||||||
+ (BOOL)requiresMainQueueSetup
|
+ (BOOL)requiresMainQueueSetup
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
|
4
src/index.d.ts
vendored
4
src/index.d.ts
vendored
@ -1141,6 +1141,9 @@ declare module 'react-native-firebase' {
|
|||||||
deleteChannel(channelId: string): Promise<void>;
|
deleteChannel(channelId: string): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BackgroundFetchResultValue = string;
|
||||||
|
type CompletionHandler = (backgroundFetchResult: BackgroundFetchResultValue) => void;
|
||||||
|
|
||||||
interface Notifications {
|
interface Notifications {
|
||||||
android: AndroidNotifications;
|
android: AndroidNotifications;
|
||||||
|
|
||||||
@ -1475,6 +1478,7 @@ declare module 'react-native-firebase' {
|
|||||||
hasAction?: boolean;
|
hasAction?: boolean;
|
||||||
launchImage?: string;
|
launchImage?: string;
|
||||||
threadIdentifier?: string;
|
threadIdentifier?: string;
|
||||||
|
complete?: CompletionHandler;
|
||||||
|
|
||||||
addAttachment(
|
addAttachment(
|
||||||
identifier: string,
|
identifier: string,
|
||||||
|
@ -3,11 +3,17 @@
|
|||||||
* IOSNotification representation wrapper
|
* IOSNotification representation wrapper
|
||||||
*/
|
*/
|
||||||
import type Notification from './Notification';
|
import type Notification from './Notification';
|
||||||
|
import type Notifications from '.';
|
||||||
|
import { type BackgroundFetchResultValue } from './IOSNotifications';
|
||||||
import type {
|
import type {
|
||||||
IOSAttachment,
|
IOSAttachment,
|
||||||
IOSAttachmentOptions,
|
IOSAttachmentOptions,
|
||||||
NativeIOSNotification,
|
NativeIOSNotification,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
import { getLogger } from '../../utils/log';
|
||||||
|
import { getNativeModule } from '../../utils/native';
|
||||||
|
|
||||||
|
type CompletionHandler = BackgroundFetchResultValue => void;
|
||||||
|
|
||||||
export default class IOSNotification {
|
export default class IOSNotification {
|
||||||
_alertAction: string | void;
|
_alertAction: string | void;
|
||||||
@ -31,7 +37,13 @@ export default class IOSNotification {
|
|||||||
|
|
||||||
_threadIdentifier: string | void; // N/A | threadIdentifier
|
_threadIdentifier: string | void; // N/A | threadIdentifier
|
||||||
|
|
||||||
constructor(notification: Notification, data?: NativeIOSNotification) {
|
_complete: CompletionHandler;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
notification: Notification,
|
||||||
|
notifications: Notifications,
|
||||||
|
data?: NativeIOSNotification
|
||||||
|
) {
|
||||||
this._notification = notification;
|
this._notification = notification;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -44,6 +56,20 @@ export default class IOSNotification {
|
|||||||
this._threadIdentifier = data.threadIdentifier;
|
this._threadIdentifier = data.threadIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const complete = (fetchResult: BackgroundFetchResultValue) => {
|
||||||
|
const { notificationId } = notification;
|
||||||
|
getLogger(notifications).debug(
|
||||||
|
`Completion handler called for notificationId=${notificationId}`
|
||||||
|
);
|
||||||
|
getNativeModule(notifications).complete(notificationId, fetchResult);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (notifications.ios.shouldAutoComplete) {
|
||||||
|
complete(notifications.ios.backgroundFetchResult.noData);
|
||||||
|
} else {
|
||||||
|
this._complete = complete;
|
||||||
|
}
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
this._attachments = this._attachments || [];
|
this._attachments = this._attachments || [];
|
||||||
}
|
}
|
||||||
@ -76,6 +102,10 @@ export default class IOSNotification {
|
|||||||
return this._threadIdentifier;
|
return this._threadIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get complete(): CompletionHandler {
|
||||||
|
return this._complete;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param identifier
|
* @param identifier
|
||||||
|
31
src/modules/notifications/IOSNotifications.js
Normal file
31
src/modules/notifications/IOSNotifications.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import { getNativeModule } from '../../utils/native';
|
||||||
|
|
||||||
|
import type Notifications from '.';
|
||||||
|
|
||||||
|
export type BackgroundFetchResultValue = string;
|
||||||
|
type BackgroundFetchResult = {
|
||||||
|
noData: BackgroundFetchResultValue,
|
||||||
|
newData: BackgroundFetchResultValue,
|
||||||
|
failure: BackgroundFetchResultValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class IOSNotifications {
|
||||||
|
_backgroundFetchResult: BackgroundFetchResult;
|
||||||
|
|
||||||
|
shouldAutoComplete: boolean;
|
||||||
|
|
||||||
|
constructor(notifications: Notifications) {
|
||||||
|
this.shouldAutoComplete = true;
|
||||||
|
|
||||||
|
const nativeModule = getNativeModule(notifications);
|
||||||
|
this._backgroundFetchResult = {
|
||||||
|
noData: nativeModule.backgroundFetchResultNoData,
|
||||||
|
newData: nativeModule.backgroundFetchResultNewData,
|
||||||
|
failure: nativeModule.backgroundFetchResultFailure,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
get backgroundFetchResult(): BackgroundFetchResult {
|
||||||
|
return { ...this._backgroundFetchResult };
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ import IOSNotification from './IOSNotification';
|
|||||||
import { generatePushID, isObject } from '../../utils';
|
import { generatePushID, isObject } from '../../utils';
|
||||||
|
|
||||||
import type { NativeNotification } from './types';
|
import type { NativeNotification } from './types';
|
||||||
|
import type Notifications from '.';
|
||||||
|
|
||||||
export type NotificationOpen = {|
|
export type NotificationOpen = {|
|
||||||
action: string,
|
action: string,
|
||||||
@ -37,19 +38,29 @@ export default class Notification {
|
|||||||
// N/A | subtitle | subText
|
// N/A | subtitle | subText
|
||||||
_title: string; // alertTitle | title | contentTitle
|
_title: string; // alertTitle | title | contentTitle
|
||||||
|
|
||||||
constructor(data?: NativeNotification) {
|
constructor(
|
||||||
this._android = new AndroidNotification(this, data && data.android);
|
nativeNotification?: NativeNotification,
|
||||||
this._ios = new IOSNotification(this, data && data.ios);
|
notifications: Notifications
|
||||||
|
) {
|
||||||
if (data) {
|
if (nativeNotification) {
|
||||||
this._body = data.body;
|
this._body = nativeNotification.body;
|
||||||
this._data = data.data;
|
this._data = nativeNotification.data;
|
||||||
this._notificationId = data.notificationId;
|
this._notificationId = nativeNotification.notificationId;
|
||||||
this._sound = data.sound;
|
this._sound = nativeNotification.sound;
|
||||||
this._subtitle = data.subtitle;
|
this._subtitle = nativeNotification.subtitle;
|
||||||
this._title = data.title;
|
this._title = nativeNotification.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._android = new AndroidNotification(
|
||||||
|
this,
|
||||||
|
nativeNotification && nativeNotification.android
|
||||||
|
);
|
||||||
|
this._ios = new IOSNotification(
|
||||||
|
this,
|
||||||
|
notifications,
|
||||||
|
nativeNotification && nativeNotification.ios
|
||||||
|
);
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
this._data = this._data || {};
|
this._data = this._data || {};
|
||||||
// TODO: Is this the best way to generate an ID?
|
// TODO: Is this the best way to generate an ID?
|
||||||
|
@ -12,6 +12,7 @@ import AndroidAction from './AndroidAction';
|
|||||||
import AndroidChannel from './AndroidChannel';
|
import AndroidChannel from './AndroidChannel';
|
||||||
import AndroidChannelGroup from './AndroidChannelGroup';
|
import AndroidChannelGroup from './AndroidChannelGroup';
|
||||||
import AndroidNotifications from './AndroidNotifications';
|
import AndroidNotifications from './AndroidNotifications';
|
||||||
|
import IOSNotifications from './IOSNotifications';
|
||||||
import AndroidRemoteInput from './AndroidRemoteInput';
|
import AndroidRemoteInput from './AndroidRemoteInput';
|
||||||
import Notification from './Notification';
|
import Notification from './Notification';
|
||||||
import {
|
import {
|
||||||
@ -74,6 +75,8 @@ export const NAMESPACE = 'notifications';
|
|||||||
export default class Notifications extends ModuleBase {
|
export default class Notifications extends ModuleBase {
|
||||||
_android: AndroidNotifications;
|
_android: AndroidNotifications;
|
||||||
|
|
||||||
|
_ios: IOSNotifications;
|
||||||
|
|
||||||
constructor(app: App) {
|
constructor(app: App) {
|
||||||
super(app, {
|
super(app, {
|
||||||
events: NATIVE_EVENTS,
|
events: NATIVE_EVENTS,
|
||||||
@ -83,6 +86,7 @@ export default class Notifications extends ModuleBase {
|
|||||||
namespace: NAMESPACE,
|
namespace: NAMESPACE,
|
||||||
});
|
});
|
||||||
this._android = new AndroidNotifications(this);
|
this._android = new AndroidNotifications(this);
|
||||||
|
this._ios = new IOSNotifications(this);
|
||||||
|
|
||||||
SharedEventEmitter.addListener(
|
SharedEventEmitter.addListener(
|
||||||
// sub to internal native event - this fans out to
|
// sub to internal native event - this fans out to
|
||||||
@ -91,7 +95,7 @@ export default class Notifications extends ModuleBase {
|
|||||||
(notification: NativeNotification) => {
|
(notification: NativeNotification) => {
|
||||||
SharedEventEmitter.emit(
|
SharedEventEmitter.emit(
|
||||||
'onNotificationDisplayed',
|
'onNotificationDisplayed',
|
||||||
new Notification(notification)
|
new Notification(notification, this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -103,7 +107,7 @@ export default class Notifications extends ModuleBase {
|
|||||||
(notificationOpen: NativeNotificationOpen) => {
|
(notificationOpen: NativeNotificationOpen) => {
|
||||||
SharedEventEmitter.emit('onNotificationOpened', {
|
SharedEventEmitter.emit('onNotificationOpened', {
|
||||||
action: notificationOpen.action,
|
action: notificationOpen.action,
|
||||||
notification: new Notification(notificationOpen.notification),
|
notification: new Notification(notificationOpen.notification, this),
|
||||||
results: notificationOpen.results,
|
results: notificationOpen.results,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -116,7 +120,7 @@ export default class Notifications extends ModuleBase {
|
|||||||
(notification: NativeNotification) => {
|
(notification: NativeNotification) => {
|
||||||
SharedEventEmitter.emit(
|
SharedEventEmitter.emit(
|
||||||
'onNotification',
|
'onNotification',
|
||||||
new Notification(notification)
|
new Notification(notification, this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -131,6 +135,10 @@ export default class Notifications extends ModuleBase {
|
|||||||
return this._android;
|
return this._android;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get ios(): IOSNotifications {
|
||||||
|
return this._ios;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel all notifications
|
* Cancel all notifications
|
||||||
*/
|
*/
|
||||||
@ -184,7 +192,7 @@ export default class Notifications extends ModuleBase {
|
|||||||
if (notificationOpen) {
|
if (notificationOpen) {
|
||||||
return {
|
return {
|
||||||
action: notificationOpen.action,
|
action: notificationOpen.action,
|
||||||
notification: new Notification(notificationOpen.notification),
|
notification: new Notification(notificationOpen.notification, this),
|
||||||
results: notificationOpen.results,
|
results: notificationOpen.results,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user