AppDelegate.m 3.44 KB
Newer Older
Lidan Hifi's avatar
Lidan Hifi committed
1
#import "AppDelegate.h"
2

yogevbd's avatar
yogevbd committed
3 4 5
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <RNNotifications/RNNotifications.h>
6

7 8
#import <PushKit/PushKit.h>

Lidan Hifi's avatar
Lidan Hifi committed
9 10 11 12 13
@implementation AppDelegate

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

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

Lidan Hifi's avatar
Lidan Hifi committed
17
  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
Lidan Hifi's avatar
Lidan Hifi committed
18
                                                      moduleName:@"NotificationsExampleApp"
Lidan Hifi's avatar
Lidan Hifi committed
19 20
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
21
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
22

Lidan Hifi's avatar
Lidan Hifi committed
23 24 25 26 27 28 29 30
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

31 32 33
// PushKit API Example
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type
{
yogevbd's avatar
yogevbd committed
34
  [[RNNotifications sharedInstance] didUpdatePushCredentials:credentials forType:type];
35 36 37 38
}

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type
{
yogevbd's avatar
yogevbd committed
39
//  [[RNNotifications sharedInstance] didReceiveRemoteNotification:payload.dictionaryPayload];
40 41
}

42 43 44

// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
Lidan Hifi's avatar
Lidan Hifi committed
45
{
yogevbd's avatar
yogevbd committed
46
//  [[RNNotifications sharedInstance] didRegisterUserNotificationSettings:notificationSettings];
Lidan Hifi's avatar
Lidan Hifi committed
47
}
48

Lidan Hifi's avatar
Lidan Hifi committed
49 50
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
yogevbd's avatar
yogevbd committed
51
  [[RNNotifications sharedInstance] didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
Lidan Hifi's avatar
Lidan Hifi committed
52 53
}

54

Lidan Hifi's avatar
Lidan Hifi committed
55
// Required for the notification event.
56
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification {
yogevbd's avatar
yogevbd committed
57
//  [[RNNotifications sharedInstance] didReceiveRemoteNotification:notification];
58 59 60 61
}

// Required for the localNotification event.
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
Lidan Hifi's avatar
Lidan Hifi committed
62
{
yogevbd's avatar
yogevbd committed
63
//  [[RNNotifications sharedInstance] didReceiveLocalNotification:notification];
Lidan Hifi's avatar
Lidan Hifi committed
64 65
}

66 67 68

// Required for the notification actions.
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void (^)())completionHandler
69
{
yogevbd's avatar
yogevbd committed
70
  [[RNNotifications sharedInstance] handleActionWithIdentifier:identifier forLocalNotification:notification withResponseInfo:responseInfo completionHandler:completionHandler];
71 72
}

73
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void (^)())completionHandler
74
{
yogevbd's avatar
yogevbd committed
75
  [[RNNotifications sharedInstance] handleActionWithIdentifier:identifier forRemoteNotification:userInfo withResponseInfo:responseInfo completionHandler:completionHandler];
76 77
}

Lidan Hifi's avatar
Lidan Hifi committed
78
@end