123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- #import "AppDelegate.h"
- #import <React/RCTBridge.h>
- #import <React/RCTBundleURLProvider.h>
- #import <React/RCTRootView.h>
- #import <MMKV/MMKV.h>
- #import <UserNotifications/UserNotifications.h>
- #import <RNCPushNotificationIOS.h>
- #ifdef FB_SONARKIT_ENABLED
- #import <FlipperKit/FlipperClient.h>
- #import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
- #import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
- #import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
- #import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
- #import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
- static void InitializeFlipper(UIApplication *application) {
- FlipperClient *client = [FlipperClient sharedClient];
- SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
- [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
- [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
- [client addPlugin:[FlipperKitReactPlugin new]];
- [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
- [client start];
- }
- #endif
- @implementation AppDelegate
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- #ifdef FB_SONARKIT_ENABLED
- InitializeFlipper(application);
- #endif
- // init MMKV in the main thread
- [MMKV initializeMMKV:nil];
- RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
- RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
- moduleName:@"Umora"
- initialProperties:nil];
- if (@available(iOS 13.0, *)) {
- rootView.backgroundColor = [UIColor systemBackgroundColor];
- } else {
- rootView.backgroundColor = [UIColor whiteColor];
- }
- self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
- UIViewController *rootViewController = [UIViewController new];
- rootViewController.view = rootView;
- self.window.rootViewController = rootViewController;
- [self.window makeKeyAndVisible];
-
- // ---- push-notification-ios ----- //
- // Define UNUserNotificationCenter
- UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
- center.delegate = self;
- // ---- push-notification-ios ----- //
-
- return YES;
- }
- - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
- {
- #if DEBUG
- return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
- #else
- return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
- #endif
- }
- // ---- push-notification-ios ----- //
- //Called when a notification is delivered to a foreground app.
- -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
- {
- completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
- }
- // Required for the register event.
- - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
- {
- [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
- }
- // Required for the notification event. You must call the completion handler after handling the remote notification.
- - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
- fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
- {
- [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
- }
- // Required for the registrationError event.
- - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
- {
- [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
- }
- // Required for localNotification event
- - (void)userNotificationCenter:(UNUserNotificationCenter *)center
- didReceiveNotificationResponse:(UNNotificationResponse *)response
- withCompletionHandler:(void (^)(void))completionHandler
- {
- [RNCPushNotificationIOS didReceiveNotificationResponse:response];
- }
- // ---- push-notification-ios ----- //
- @end
|