第三方应用跳转到京东app

2018-11-28  本文已影响0人  不泯iOS

方式一、通过集成京东联盟sdk实现(通过这种方式可以实现跳转到京东后,有返回第三方应用的返回键功能)

步骤

选择app管理.png
#import <JDSDK/JDKeplerSDK.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   // Override point for customization after application launch.
   ........
   
   //注册Kepler服务
   [[KeplerApiManager sharedKPService]asyncInitSdk:@"填入appkey" secretKey:@"填入appsecret" sucessCallback:^{
       NSLog(@"注册成功");
   } failedCallback:^(NSError *error) {
       NSLog(@"注册失败");
   }];

  ........
   return YES;
}
if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:[NSString stringWithFormat:@"openapp.jdmobile://"]]]) {//判断是否安装京东app
                    [[KeplerApiManager sharedKPService]openKeplerPageWithURL:@"url" userInfo:nil failedCallback:^(NSInteger code, NSString *url) {
                        NSLog(@"code:%ld,url:%@",(long)code,url);
                    }];
                }else{
                    //可以自己写个网页打开
                }

方式二、直接通过URL Scheme判断进行跳转

        if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:[NSString stringWithFormat:@"openapp.jdmobile://"]]]) {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"openapp.jdmobile://"]]];
        }else{
            //可以自己写个网页打开
        }

上一篇 下一篇

猜你喜欢

热点阅读