Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Push notifications] Check for RCTPushNotificationManager.
This will prevent the user from adding the code to the app delegate
when they want to use the Pushnotifications.
  • Loading branch information
DannyvanderJagt committed Aug 13, 2015
commit 9da90e509bcfa4646149a2c4aaf88363cb902e4e
2 changes: 2 additions & 0 deletions Examples/SampleApp/SampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../Libraries/**",
"$(SRCROOT)/../../React/**",
);
INFOPLIST_FILE = "iOS/Info.plist";
Expand All @@ -614,6 +615,7 @@
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../Libraries/**",
"$(SRCROOT)/../../React/**",
);
INFOPLIST_FILE = "iOS/Info.plist";
Expand Down
18 changes: 18 additions & 0 deletions Examples/SampleApp/iOS/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

@implementation AppDelegate

Class RCTPushNotificationManager = nil;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
Expand Down Expand Up @@ -49,6 +51,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
moduleName:@"SampleApp"
launchOptions:launchOptions];

RCTPushNotificationManager = NSClassFromString(@"RCTPushNotificationManager");

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [[UIViewController alloc] init];
rootViewController.view = rootView;
Expand All @@ -57,4 +61,18 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
if(RCTPushNotificationManager){
[RCTPushNotificationManager application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification
{
if(RCTPushNotificationManager){
[RCTPushNotificationManager application:application didReceiveRemoteNotification:notification];
}
}

@end