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 3.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  23. {
  24. RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  25. RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil];
  26. rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
  27. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  28. UIViewController *rootViewController = [UIViewController new];
  29. rootViewController.view = rootView;
  30. self.window.rootViewController = rootViewController;
  31. [self.window makeKeyAndVisible];
  32. // Define UNUserNotificationCenter
  33. UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  34. center.delegate = self;
  35. [RNSplashScreen show];
  36. return YES;
  37. }
  38. //Called when a notification is delivered to a foreground app.
  39. -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
  40. {
  41. completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
  42. }
  43. // Required to register for notifications
  44. - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
  45. {
  46. [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings];
  47. }
  48. // Required for the register event.
  49. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
  50. {
  51. [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
  52. }
  53. // Required for the notification event. You must call the completion handler after handling the remote notification.
  54. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
  55. fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
  56. {
  57. [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
  58. }
  59. // Required for the registrationError event.
  60. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
  61. {
  62. [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
  63. }
  64. // Required for the localNotification event.
  65. - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
  66. {
  67. [RNCPushNotificationIOS didReceiveLocalNotification:notification];
  68. }
  69. - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
  70. #ifdef DEBUG
  71. return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  72. #else
  73. return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  74. #endif
  75. }
  76. @end