iOS中如何判断是否安装了某个应用

如果公司有多款产品A B C,有时候需要在A和B中判断C时候已经安装。

首先需要看到C的url schema,方法是:

  • 工程 - Target
  • Info标签
  • URL Types
  • 添加或选中当前identifier的UrlSchema

形如:product23445343242

然后代码:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
+ (BOOL)canOpenScheme:(NSString *)scheme {
NSURL * url = [NSURL URLWithString:scheme];
return [[UIApplication sharedApplication] canOpenURL:url];
}
+ (BOOL)canOpenScheme:(NSString *)scheme { NSURL * url = [NSURL URLWithString:scheme]; return [[UIApplication sharedApplication] canOpenURL:url]; }
+ (BOOL)canOpenScheme:(NSString *)scheme {
    NSURL * url = [NSURL URLWithString:scheme];
    return [[UIApplication sharedApplication] canOpenURL:url];
}

其中schema中传入product23445343242://open

Leave a Reply

Your email address will not be published. Required fields are marked *