目前專案中使用了pingpp-react-native
這個模組,
他在文件中說到需要在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;
}
我的AppDelegate.m如下,目前只加了iOS9的程式碼,請問iOS8的那塊程式碼如何加,看起來是要跟RCTLinkingManager那塊合併?
#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