AppDelegate.m 2.54 KB
Newer Older
renato's avatar
renato committed
1 2 3 4 5 6 7 8 9 10 11
/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import "AppDelegate.h"

Libin Lu's avatar
Libin Lu committed
12
#import <React/RCTBundleURLProvider.h>
renato's avatar
renato committed
13 14
#import "RCTRootView.h"

renato's avatar
renato committed
15 16
#import "RNFIRMessaging.h"

renato's avatar
renato committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"SimpleFcmClient"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
renato's avatar
renato committed
36 37 38 39
  
  [FIRApp configure];
  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
  
renato's avatar
renato committed
40 41 42
  return YES;
}

Libin Lu's avatar
Libin Lu committed
43 44
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
Libin Lu's avatar
Libin Lu committed
45
  [RNFIRMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
renato's avatar
renato committed
46 47
}

Libin Lu's avatar
Libin Lu committed
48
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
Libin Lu's avatar
Libin Lu committed
49
{
Libin Lu's avatar
Libin Lu committed
50
  [RNFIRMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
renato's avatar
renato committed
51
}
Libin Lu's avatar
Libin Lu committed
52 53

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
Libin Lu's avatar
Libin Lu committed
54
  [RNFIRMessaging didReceiveLocalNotification:notification];
renato's avatar
renato committed
55 56 57
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
Libin Lu's avatar
Libin Lu committed
58
  [RNFIRMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
renato's avatar
renato committed
59 60
}

renato's avatar
renato committed
61
@end