Files
react-native-notifications/RNNotifications/RNNotificationParser.m
2019-08-13 14:53:36 +03:00

28 lines
1.1 KiB
Objective-C

#import "RNNotificationParser.h"
#import "RCTConvert+RNNotifications.h"
@implementation RNNotificationParser
+ (NSDictionary *)parseNotification:(UNNotification *)notification {
return [RCTConvert UNNotificationPayload:notification];
}
+ (NSDictionary *)parseNotificationResponse:(UNNotificationResponse *)response {
NSDictionary* responseDict = @{@"notification": [RCTConvert UNNotificationPayload:response.notification], @"identifier": response.notification.request.identifier, @"action": [self parseNotificationResponseAction:response]};
return responseDict;
}
+ (NSDictionary *)parseNotificationResponseAction:(UNNotificationResponse *)response {
NSMutableDictionary* responseAction = [NSMutableDictionary dictionaryWithDictionary:@{@"identifier": response.actionIdentifier}];
NSString* responseText = [response isKindOfClass:[UNTextInputNotificationResponse class]] ? ((UNTextInputNotificationResponse *)response).userText : nil;
if (responseText) {
[responseAction setObject:responseText forKey:@"text"];
}
return responseAction;
}
@end