Hi,
I get the following error on Xcode when passing autoRegister:false to initWithLaunchOptions to allow me to manually request notifications permission on iOS:
No visible @interface for 'RCTOneSignal' declares the selector 'initWithLaunchOptions:appId:autoRegister'
Without autoRegister:false everything works fine.
react-native: 0.39.2
react-native-onesignal: 2.0.0
Installed with cocoapods
Anybody knows what I did wrong?
Here's my AppDelegate.m
#import "AppDelegate.h"
#import "RCTBundleURLProvider.h"
#import "RCTRootView.h"
#import "SplashScreen.h"
#import "RCTOneSignal.h"
@implementation AppDelegate
@synthesize oneSignal = _oneSignal;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"moduleName"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.oneSignal = [[RCTOneSignal alloc] initWithLaunchOptions:launchOptions
appId:@"myAppId"
autoRegister:false]; <-- error
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[SplashScreen show];
return YES;
}
// Required for the notification event.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification {
[RCTOneSignal didReceiveRemoteNotification:notification];
}
@end
That's our fault, the docs are not updated with the right parameter. autoRegister is not available anymore since version 2.0.0. Instead, you have another settings parameters.
Please see my answer here:
https://github.com/geektimecoil/react-native-onesignal/issues/157#issuecomment-274646754
Hi @avishayil,
I managed to get it working with:
self.oneSignal = [[RCTOneSignal alloc] initWithLaunchOptions:launchOptions
appId:@"myAppId"
settings:@{kOSSettingsKeyAutoPrompt: @false}];
Thanks for the help!
Most helpful comment
Hi @avishayil,
I managed to get it working with:
Thanks for the help!