Application Android et IOS pour l'amicale des élèves
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.5KB

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