diff --git a/native/ios/Comm/CommIOSNotifications/CommIOSNotifications.mm b/native/ios/Comm/CommIOSNotifications/CommIOSNotifications.mm --- a/native/ios/Comm/CommIOSNotifications/CommIOSNotifications.mm +++ b/native/ios/Comm/CommIOSNotifications/CommIOSNotifications.mm @@ -1,6 +1,7 @@ #import "CommIOSNotifications.h" #import "CommIOSNotificationsBridgeQueue.h" #import +#import #import #import #import @@ -17,6 +18,24 @@ @"CommIOSNotificationsReceivedForeground"; NSString *const CommIOSNotificationsOpened = @"CommIOSNotificationsOpened"; +/* + UIBackgroundFetchResult enum converter to pass fetch result value + between Objective - C and JavaScript +*/ +@implementation RCTConvert (UIBackgroundFetchResult) + +RCT_ENUM_CONVERTER( + UIBackgroundFetchResult, + (@{ + @"UIBackgroundFetchResultNewData" : @(UIBackgroundFetchResultNewData), + @"UIBackgroundFetchResultNoData" : @(UIBackgroundFetchResultNoData), + @"UIBackgroundFetchResultFailed" : @(UIBackgroundFetchResultFailed), + }), + UIBackgroundFetchResultNoData, + integerValue) + +@end + @implementation CommIOSNotifications RCT_EXPORT_MODULE() @@ -84,6 +103,21 @@ ]; } +/* + Constants used un JavaScript +*/ +- (NSDictionary *)constantsToExport { + return @{ + @"FETCH_RESULT_NEW_DATA" : @"UIBackgroundFetchResultNewData", + @"FETCH_RESULT_NO_DATA" : @"UIBackgroundFetchResultNoData", + @"FETCH_RESULT_FAILED" : @"UIBackgroundFetchResultFailed" + }; +} + ++ (BOOL)requiresMainQueueSetup { + return YES; +} + /* Public methods */