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

3

22

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
Amphimacer answered 22/9, 2015 at 16:58 Comment(1)
I have this problem only when run app on emulator. Have you solve it?Grimalkin
S
13

This problem only happens in iOS 9 since Apple made some changes impacting URL schemes.

I think that one of your libraries is checking to see if you are running on a jailbroken device by checking if it can open cydia://URL...

"Up until iOS 9, apps have been able to call these methods on any arbitrary URLs. Starting on iOS 9, apps will have to declare what URL schemes they would like to be able to check for and open in the configuration files of the app as it is submitted to Apple"

Link: http://awkwardhare.com/post/121196006730/quick-take-on-ios-9-url-scheme-changes

Seeker answered 30/9, 2015 at 17:0 Comment(2)
Will Apple reject a submission if "cydia" is added to whitelist in app's plist?Downey
@Downey - Will Apple reject a submission if "cydia" is added to whitelist in app's plist?Druse
S
25

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>
Snowshed answered 27/10, 2015 at 9:32 Comment(0)
S
13

This problem only happens in iOS 9 since Apple made some changes impacting URL schemes.

I think that one of your libraries is checking to see if you are running on a jailbroken device by checking if it can open cydia://URL...

"Up until iOS 9, apps have been able to call these methods on any arbitrary URLs. Starting on iOS 9, apps will have to declare what URL schemes they would like to be able to check for and open in the configuration files of the app as it is submitted to Apple"

Link: http://awkwardhare.com/post/121196006730/quick-take-on-ios-9-url-scheme-changes

Seeker answered 30/9, 2015 at 17:0 Comment(2)
Will Apple reject a submission if "cydia" is added to whitelist in app's plist?Downey
@Downey - Will Apple reject a submission if "cydia" is added to whitelist in app's plist?Druse
L
-2

Delete the Splunk Mint framework if you have it added in the project because Xcode 7 does not support the framework.

Also add this key to your .plist :

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
Lustihood answered 23/1, 2017 at 15:17 Comment(1)
While this solves the problem. It's not the best option for the sake of cybersecurity to allow for unsecured http requests on the app. Which is what this does.Dizzy

© 2022 - 2024 — McMap. All rights reserved.