RNPushKitEventListener.m 950 Bytes
Newer Older
1
#import "RNPushKitEventListener.h"
2
#import "RNNotificationUtils.h"
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

@implementation RNPushKitEventListener {
    PKPushRegistry* _pushRegistry;
    RNPushKitEventHandler* _pushKitEventHandler;
}

- (instancetype)initWithPushKitEventHandler:(RNPushKitEventHandler *)pushKitEventHandler {
    self = [super init];
    
    _pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
    _pushKitEventHandler = pushKitEventHandler;
    
    return self;
}

- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
19
    [_pushKitEventHandler registeredWithToken:[RNNotificationUtils deviceTokenToString:credentials.token]];
20 21 22
}

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {
yogevbd's avatar
yogevbd committed
23
    [_pushKitEventHandler didReceiveIncomingPushWithPayload:payload.dictionaryPayload];
24 25 26
}

@end