"This app is not allowed to query for scheme cydia" IOS9 error

Rahul Singh picture Rahul Singh · Sep 22, 2015 · Viewed 19.8k times · Source

I have an app where I hit a HTTP Request

<NSURLConnection: 0x12d755110> { request: <NSMutableURLRequest: 0x12d754e10> { URL: http://XX.XX.XX.XXX/webService/dataService.svc/SearchLocation } }

Now, whenever the above request is made I get the following error and no data is received in the response. After 60 Sec I get "Time Out error". It is working fine on IOS8 and below but not working gin IOS9. Could anybody let me know what else have I got to do with this issue. Also, I have done the following changes regarding ATS for iOS9 in info.plist, but still facing the issue. Please let me know how to fix this? Thanks in advance.

Info.plist

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSIncludesSubdomains</key>
        <true/>
        <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
        <true/>
        <key>NSTemporaryExceptionMinimumTLSVersion</key>
        <string>TLSv1.1</string>
    </dict>

Error

2015-09-22 22:19:58.333 App[751:139449] regionDidChangeAnimated>>>>>>>>>>>>>>>>>: = 40.844278,-74.130561
2015-09-22 22:19:58.344 App[751:139449] Reachability Flag Status: -R ------- networkStatusForFlags
2015-09-22 22:19:58.350 App[751:139449] request:< SearchLocation ><DeviceKeyUDID>My Device UDID</DeviceKeyUDID><SecretKey>SecretKey/SecretKey><ListingType>LOCATION</ListingType><PageIndex>1</PageIndex><MaxNoOfRecords>20</MaxNoOfRecords><Latitude>40.844276</Latitude><Longitude>-74.130562</Longitude><Distance>25</Distance><Address></Address><SearchText></SearchText></SearchLocation >
2015-09-22 22:19:58.357 App[751:139449] -canOpenURL: failed for URL: "cydia://package/com.fake.package" - error: "This app is not allowed to query for scheme cydia"
2015-09-22 22:19:58.945 App[751:139449] theXML contains:
2015-09-22 22:19:58.959 App[751:139449] refreshLocationList maxRecordsSelected:::::::::::::20
2015-09-22 22:19:58.960 App[751:139449] refreshLocationList maxNumOfRecords:::::::::::::20
2015-09-22 22:19:58.960 App[751:139449] refreshLocationList LocationCount::::::::::::::0
2015-09-22 22:19:58.960 App[751:139449] isTempleMaxRecordChanged :::::::::::::0

Answer

Mitul Marsoniya picture Mitul Marsoniya · Oct 27, 2015

First solution:- just add bellow code in your info.plist

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

Second solution:-

Any app built with SDK 9 needs to provide a LSApplicationQueriesSchemes entry in its plist file, declaring which schemes it attempts to query.

<key>LSApplicationQueriesSchemes</key>
<array>
 <string>urlscheme</string>
 <string>urlscheme2</string>
 <string>urlscheme3</string>
 <string>urlscheme4</string>
</array> 

Assuming two apps TestA and TestB. TestB wants to query if TestA is installed. "TestA" defines the following URL scheme in its info.plist file:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>testA</string>
        </array>
    </dict>
</array>

The second app "TestB" tries to find out if "TestA" is installed by calling:

[[UIApplication sharedApplication]
                    canOpenURL:[NSURL URLWithString:@"TestA://"]];

But this will normally return NO in iOS9 because "TestA" needs to be added to the LSApplicationQueriesSchemes entry in TestB's info.plist file. This is done by adding the following code to TestB's info.plist file:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>TestA</string>
</array>