search

Home  >  Q&A  >  body text

react-native - A problem with react native ios AppDelegate.m

The pingpp-react-native module is currently used in the project.
He mentioned in the document that the following code needs to be added to AppDelegate.m,

//iOS 8 及以下
- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    BOOL canHandleURL = [Pingpp handleOpenURL:url withCompletion:nil];
    return canHandleURL;
}
//iOS 9 及以上
- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary *)options {
    BOOL canHandleURL = [Pingpp handleOpenURL:url withCompletion:nil];
    return canHandleURL;
}

My AppDelegate.m is as follows. Currently, only the iOS9 code has been added. How to add the iOS8 code? It seems that it needs to be merged with the RCTLinkingManager code?

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLinkingManager.h>
#import "SplashScreen.h"
#import "Pingpp.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  // 省略
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  return [RCTLinkingManager application:application openURL:url
                      sourceApplication:sourceApplication annotation:annotation];
}

// 我添加的pingpp iOS9相关代码
- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary *)options {
  BOOL canHandleURL = [Pingpp handleOpenURL:url withCompletion:nil];
  return canHandleURL;
}

@end
迷茫迷茫2723 days ago957

reply all(1)I'll reply

  • PHPz

    PHPz2017-05-31 10:34:55

    If you need to adapt to iOS8, you can judge the version in two ways

    reply
    0
  • Cancelreply