zoukankan      html  css  js  c++  java
  • 根据appid跳到App Store某个APP的详情页

    需求

    本手机是否装了某个APP 示例百度appid 382201985  scheme BaiduSSO://

    1.是,直接打开百度APP

    2.否,跳到App Store百度APP的详情页

    NSString *aScheme = @"BaiduSSO://";

        NSString *aAppleId = @"382201985";

        NSURL*aAppUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@://", aScheme]];

    //打开某个APP

        [[UIApplication sharedApplication] openURL:aAppUrl options:@{} completionHandler:^(BOOL success) {

            if (!success) {

    //跳到App Store某个APP的详情页

               [self showAppStoreWithAppId:aAppleId];

            }

        }];

    导入头文件 

    #import <StoreKit/StoreKit.h>

    加代理

    SKStoreProductViewControllerDelegate

     

    -(void)showAppStoreWithAppId:(NSString *)appId

    {

        SKStoreProductViewController *appStore = [[SKStoreProductViewController alloc] init];

        appStore.delegate = self;

        [appStore loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:appId} completionBlock:^(BOOL result, NSError * _Nullable error) {

            if (error) {

                NSLog(@"错误 %@",error);

            } else {

            }

        }];

        [self presentViewController:appStore animated:YES completion:nil];

    }

    - (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController

    {

        [viewController dismissViewControllerAnimated:YES completion:nil];

    }

  • 相关阅读:
    数据库相关
    linux相关
    类相关
    异常处理
    一些类的概念
    安装插件
    接口开发
    redis相关
    大数据-概览
    大数据-浅谈OLTP与OLAP
  • 原文地址:https://www.cnblogs.com/huangzs/p/13533412.html
Copyright © 2011-2022 走看看