Application Android et IOS pour l'amicale des élèves https://play.google.com/store/apps/details?id=fr.amicaleinsat.application
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AppDelegate.m 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import "AppDelegate.h"
  8. #import <React/RCTBundleURLProvider.h>
  9. #import <React/RCTRootView.h>
  10. #import <React/RCTLinkingManager.h>
  11. #import "RNSplashScreen.h"
  12. #import <RNCPushNotificationIOS.h>
  13. #import <UserNotifications/UserNotifications.h>
  14. #ifdef FB_SONARKIT_ENABLED
  15. #import <FlipperKit/FlipperClient.h>
  16. #import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
  17. #import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
  18. #import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
  19. #import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
  20. #import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
  21. static void InitializeFlipper(UIApplication *application) {
  22. FlipperClient *client = [FlipperClient sharedClient];
  23. SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
  24. [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
  25. [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
  26. [client addPlugin:[FlipperKitReactPlugin new]];
  27. [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
  28. [client start];
  29. }
  30. #endif
  31. @implementation AppDelegate
  32. @synthesize window = _window;
  33. - (BOOL)application:(UIApplication *)application
  34. openURL:(NSURL *)url
  35. options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
  36. {
  37. return [RCTLinkingManager application:application openURL:url options:options];
  38. }
  39. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  40. {
  41. #ifdef FB_SONARKIT_ENABLED
  42. InitializeFlipper(application);
  43. #endif
  44. RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  45. RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"Campus" initialProperties:nil];
  46. if (@available(iOS 13.0, *)) {
  47. rootView.backgroundColor = [UIColor systemBackgroundColor];
  48. } else {
  49. rootView.backgroundColor = [UIColor whiteColor];
  50. }
  51. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  52. UIViewController *rootViewController = [UIViewController new];
  53. rootViewController.view = rootView;
  54. self.window.rootViewController = rootViewController;
  55. [self.window makeKeyAndVisible];
  56. // Define UNUserNotificationCenter
  57. UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  58. center.delegate = self;
  59. [RNSplashScreen show];
  60. return YES;
  61. }
  62. //Called when a notification is delivered to a foreground app.
  63. -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
  64. {
  65. completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
  66. }
  67. // Required to register for notifications
  68. - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
  69. {
  70. [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings];
  71. }
  72. // Required for the register event.
  73. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
  74. {
  75. [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
  76. }
  77. // Required for the notification event. You must call the completion handler after handling the remote notification.
  78. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
  79. fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
  80. {
  81. [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
  82. }
  83. // Required for the registrationError event.
  84. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
  85. {
  86. [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
  87. }
  88. // Required for the localNotification event.
  89. - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
  90. {
  91. [RNCPushNotificationIOS didReceiveLocalNotification:notification];
  92. }
  93. - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
  94. #ifdef DEBUG
  95. return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  96. #else
  97. return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  98. #endif
  99. }
  100. @end