Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Is there a way to call my native module interface in my app delegate?

$
0
0

I am new to ios development and I'm trying to use the Spotify SDK in my native module for my react native project. Im following the tutorial here https://developer.spotify.com/documentation/ios/quick-start/objective-c/#configure-info-plist but I'm implementing it in my native module which does not have an App delagte. I need to call my interface's function from my main projects App delegate but it does not work.

I have tried creating a shared instance to access the interfaces but each time I get the instance they are in different memory locations and the second is always null.

In my AppDelegate.m I am getting a shared instance of my controller interface in order to return the results to the instance.

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  return [[RNSpotifyController sharedInstance]application:app
                                                       openURL:url
                                                       options:options];

In my RNSpotifyController.m I have

- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{

    NSLog(@"%@ %@", url, options);



//    return [self.sessionManager application:RCTSharedApplication() 
    return [self.sessionManager application:application openURL:url options:options];
}

and

+ (RNSpotifyController *)sharedInstance
{
  static RNSpotifyController *_sharedInstance;
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    _sharedInstance = [[self alloc] init];
  });
  return _sharedInstance;
}

I expect whenever I get a shared Instance it would be the same as all other instances but it is not. I just need to be able to call my interface's method from my app delegate. The shared instance is different from the initial interface that is initialized. Let me know if any more code would be helpful


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>