• 根据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];

    }

  • 相关阅读:
    误区30日谈25-30
    误区30日谈21-24
    误区30日谈16-20
    误区30日谈11-15
    误区30日谈6-10
    eclipse如何导入java项目文件
    Spring配置bean文件的底层实现方式
    hibernate中get,load,list,iterate的用法及比较
    MySQL数据库的事务管理
    单元格样式
  • 原文地址:https://www.cnblogs.com/huangzs/p/13533412.html
Copyright © 2020-2023  润新知