-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventEmitter.m
62 lines (45 loc) · 1.26 KB
/
EventEmitter.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// EventEmitter.m
// BlueWallet
//
// Created by Marcos Rodriguez on 12/25/20.
// Copyright © 2020 BlueWallet. All rights reserved.
//
#import "EventEmitter.h"
static EventEmitter *sharedInstance;
@implementation EventEmitter
RCT_EXPORT_MODULE();
+ (BOOL)requiresMainQueueSetup {
return YES;
}
+ (EventEmitter *)sharedInstance {
return sharedInstance;
}
- (void)removeListeners:(double)count {
}
- (instancetype)init {
sharedInstance = [super init];
return sharedInstance;
}
- (NSArray<NSString *> *)supportedEvents {
return @[@"onNotificationReceived",@"openSettings",@"onUserActivityOpen"];
}
- (void)sendNotification:(NSDictionary *)userInfo
{
[sharedInstance sendEventWithName:@"onNotificationReceived" body:userInfo];
}
- (void)sendUserActivity:(NSDictionary *)userInfo
{
[sharedInstance sendEventWithName:@"onUserActivityOpen" body:userInfo];
}
RCT_REMAP_METHOD(getMostRecentUserActivity, resolve: (RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
{
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.io.bluewallet.bluewallet"];
resolve([defaults valueForKey:@"onUserActivityOpen"]);
}
- (void)openSettings
{
[sharedInstance sendEventWithName:@"openSettings" body:nil];
}
@end