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 @@ -45,6 +46,24 @@ return formattedNotification; } +/* + 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 + @interface CommIOSNotifications () @property(nonatomic, strong) NSMutableDictionary *remoteNotificationCallbacks; @end @@ -119,6 +138,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 */