Closed haorh closed 3 years ago
Howdy, Can you please upgrade to the latest version of the SDK?
I see going to version 4.x.x require RN0.6x. I cannot afford to upgrade to RN0.6x now as i would need to check ALL my dependencies, which I know a lot will break. I have tried upgrade to react-native-onesignal@3.9.3 and placed console.log at checkIfInitialized(), its the same result (works on android). I think its something wrong related to my xcode/cocoapod. Based on podlock, the installed onesignal version is 3.4.1
If i follow iOS SDK setup and place OneSignal initWithLaunchOptions:launchOptions appId:@"xxxxx"];
at AppDelegate.m, onesignal dashboard shows iOS Simulator Unsupported. So I assume this means my one signal files are at correct place, its just that the linkage to JS is broken as NativeModules.OneSignal return null. How does one-signal exports the native function to JS side? I cannot find in RCT_EXPORT_MODULE within the files under RCTOneSignal folder. nvm its at RCTOnesignalEventEmitter.m
My AppDelegate.m
#import "AppDelegate.h"
#import <OneSignal/OneSignal.h> <-- this works
#import <CodePush/CodePush.h>
#import "Orientation.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <AVFoundation/AVFoundation.h>
#import <BugsnagReactNative/BugsnagReactNative.h>
#import <Bugsnag.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[BugsnagReactNative start];
NSURL *jsCodeLocation;
// - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
// {
#ifdef DEBUG
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
NSLog(@"-[XH] DEBUG %@", [jsCodeLocation path]);
#else
jsCodeLocation = [CodePush bundleURL];
NSLog(@"-[XH] PRODUCTION %@", [jsCodeLocation path]);
#endif
// }
[OneSignal setLogLevel:ONE_S_LL_NONE visualLevel:ONE_S_LL_NONE]; <-- this works
[OneSignal initWithLaunchOptions:launchOptions appId:@"xxxxxxxx"];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"Main"
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];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error: nil];
return YES;
}
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [Orientation getOrientation];
}
@end
Howdy, Sorry for the delayed response.
We no longer support manual linking. If you would like to support it, you can do so by following the instructions here. You will need to copy the binaries over from the native SDK.
I have tried both method and didnt work initially. Now I'm using cocoapod way and I had to implement my own .m class to export OneSignal function to js side with RCT_EXTERN_METHOD.
Glad to hear it's working now. Cheers
Description: iOS one signal never initialized but work fine in Android.
checkIfInitialized()
in react-native-onesignal's index.js always return false. In other word,NativeModules.OneSignal
was not initialized on iOS. I understand that push notification does not work at simulator but the user will still show up at one signal dashboard. However, this didnt happen anymore starting a few months ago.Environment react-native: 0.59.9 react-native-onesignal: 3.2.12 xCode: 12.4 Main project deployment target level: 9.0 OneSignal deployment target level: 10.0
Pod
Main Target -> Build Phase -> Link Binary with Libraries
Main Target -> Build Settings -> Search Paths -> FRAMEWORK_SEARCH_PATHS
Main Target -> Build Settings -> Search Paths -> HEADER_SEARCH_PATHS
OneSignal Target -> Build Phase -> Link Binary with Libraries
OneSignal Target -> Build Settings -> Search Paths -> FRAMEWORK_SEARCH_PATHS
"$(PODS_ROOT)/OneSignal/iOS_SDK/OneSignalSDK/Framework" [non-recursive]
OneSignal Target -> Build Settings -> Search Paths -> HEADER_SEARCH_PATHS
Anything else: I have tried:
'OneSignal', '>= 3.0', '< 4.0'
platform :ios, '10.0'
I still cant see user at dashboard. With v3.6.5, it works on Android but not iOS. My project was initially using manual linking, but to solve this issue (also ready to migrate to RN0.6x), I'm changing to use cocoapod so there may be some residue of manual linking config left in my xcode.
I have no log to show because
OneSignal.setLogLevel(6, 0);
return; due toif (!checkIfInitialized()) return;
I hope to remain at react-native 0.59.9 for now.