Search code examples
iossecurityxcode6ios9url-scheme

Why so many canOpenURL?


When running AlipaySDK demo from https://doc.open.alipay.com/doc2/detail?treeId=54&articleId=103419&docType=1, some odd things happened.

From the log output in xcode, there are more than 10 logs to say

-canOpenURL: failed for URL: "momochs://" - error: "This app is not allowed to query for scheme momochs

There are no source code in demo to print out such things by simple searching. And the static lib just does payment and shouldn't do such checking according to my understanding.

Question here is to figure out why this happened or something wrong for the demo or other setup ?

2016-03-02 15:58:55.998 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "momochs://" - error: "This app is not allowed to query for scheme momochs" 2016-03-02 15:58:55.999 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "tenpay://" - error: "This app is not allowed to query for scheme tenpay" 2016-03-02 15:58:55.999 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "com.icbc.iphoneclient://" - error: "This app is not allowed to query for scheme com.icbc.iphoneclient" 2016-03-02 15:58:56.000 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "wx2654d9155d70a468://" - error: "This app is not allowed to query for scheme wx2654d9155d70a468" 2016-03-02 15:58:56.000 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "meituan0000://" - error: "This app is not allowed to query for scheme meituan0000" 2016-03-02 15:58:56.000 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "sinaweibo://" - error: "This app is not allowed to query for scheme sinaweibo" 2016-03-02 15:58:56.001 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "dianping://" - error: "This app is not allowed to query for scheme dianping" 2016-03-02 15:58:56.001 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "diditaxi://" - error: "This app is not allowed to query for scheme diditaxi" 2016-03-02 15:58:56.002 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "cn.12306://" - error: "This app is not allowed to query for scheme cn.12306" 2016-03-02 15:58:56.002 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "mtxx://" - error: "This app is not allowed to query for scheme mtxx" 2016-03-02 15:58:56.002 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "youku://" - error: "This app is not allowed to query for scheme youku" 2016-03-02 15:58:56.003 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "baidumap://" - error: "This app is not allowed to query for scheme baidumap" 2016-03-02 15:58:56.003 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "iosamap://" - error: "This app is not allowed to query for scheme iosamap"


Solution

  • Why so many canOpenURL ?

    Because they want to know which apps are installed, up to iOS8 this was an ugly trick to know which apps you have installed, they basically have a list of app schemes they want to know about, so they will do consecutive canOpenURL calls for each app scheme, then harvest the data and send it back to their servers for whatever purpose they need it to.

    Thankfully this is no longer allowed in iOS9, since you need to provide the list of schemes your app will do canOpenURL calls against, calling an url scheme that's not in your info.plist will result in that log warning you see

    The odd thing is I got log information as below, but can't find any source code to print out such things.

    The SDK isn't open sourced from what I see, so there's no way for you to peek into their code, the code is inside the static libs *.a files

    Just wonder how can they do this without source code ? Any technology to >achieve this ? thanks

    It's nothing special, if you write a project and build it as a static library you'll get the compiled source in .a files, that you can import to other projects and use there, as long as you have the proper header files, this is exactly how AliPay does it

    Hope this clears up the confusion, I recommend to leave it as is, don't allow them to pull off stunts like that.

    You can always add the list of those schemes into your info.plist, but then you'll have to explain to apple yourself why you need to open so many apps, again, very bad idea, simply ignore it and you're good to go!