Software Archive
Read-only legacy content
17061 Discussions

IOS Grant Location Access not working

Honda20
Beginner
448 Views

Hi Intel Support

I have added third party plugin using below 2nd code, and added into plugin management. When app is launch it doesn't pop up/grant access location setting. Do I need to add any code in the index.html? I have also added this in the intelxdk.config.additions.xml. Can you please assist

Added in intelxdk.config.additions.xml 

<config-file target="*-Info.plist" parent="NSLocationAlwaysUsageDescription" overwrite="true">
    <array>
        <string>NSLocationAlwaysUsageDescription</string>
    </array>
</config-file>)

<?xml version="1.0" encoding="UTF-8"?>

Created plugin

<plugin
    xmlns="http://apache.org/cordova/ns/plugins/1.0"
    id="plist-plugin"
    version="0.1"
>
    <name>Plist Additions</name>
 
    <engines>
        <engine name="cordova-ios" version=">=3.0.0" />
    </engines>
 
    <platform name="ios">
        <config-file target="*-Info.plist" parent="CFBundleLocalizations">
              <array>  
                    <key>NSLocationUsageDescription</key>
                    <string>This app requires access to your location</string>
            </array>
        </config-file>
        <config-file target="*-Info.plist" parent="CFBundleLocalizations">
              <array>  
                    <key>NSLocationAlwaysUsageDescription</key>
                    <string>This app requires access to your location</string>
            </array>
        </config-file>
        <config-file target="*-Info.plist" parent="CFBundleLocalizations">
              <array>  
                    <key>NSLocationWhenInUseUsageDescription</key>
                    <string>This app requires access to your location</string>
            </array>
        </config-file>
        </platform>
</plugin>

0 Kudos
5 Replies
PaulF_IntelCorp
Employee
448 Views

Adding those lines to the additions file will not do anything, those are meant for a Cordova plugin.xml file.

I did not look closely at your plugin.xml, but to answer your question regarding "When app is launch it doesn't pop up/grant access location setting." -- that only happens when your app code attempts to access the geolocation functions. In general, you do not have to do this sort of thing because the geolocation plugin you are using will take care of adding those permissions for you. Yes, you do have to write code that will access the functions. With most plugins, this permission request will happen during initialization of the plugin, not always, but usually.

0 Kudos
Honda20
Beginner
448 Views
Hi Paul I managed to add the location setting pops up when app launch. However it will only work for url with "HTTPS" my url is HTTP without the S, is there any work around? Regards Honda20
0 Kudos
PaulF_IntelCorp
Employee
448 Views

For that I suggest you check the "Cordova" on StackOverflow for help with that issue. If you cannot find a question there that matches your issue, post your question with the Cordova tag applied. The XDK creates standard Cordova apps, so solutions for Cordova will also apply to the XDK.

0 Kudos
Honda20
Beginner
448 Views

Hi Paul

I found information from Google. 

I installed a plugin Cordova Plugin Transport Security - https://www.npmjs.com/package/cordova-plugin-transport-security

then I tried several times editing the xml (http://stackoverflow.com/questions/31254725/transport-security-has-blocked-a-cleartext-http)

1. 

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>I change to my domain</key>
        <dict>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSTemporaryExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
            <key>NSIncludesSubdomains</key>
            <true/>
        </dict>
    </dict>
</dict>

2. 

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>I change to my domain</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
            <key>NSIncludesSubdomains</key>
            <true/>
        </dict>
    </dict>
</dict>

3 even this doesnt work

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

Am I missing something?

0 Kudos
PaulF_IntelCorp
Employee
448 Views

Sorry, but we're really not experts on the details of Android security. I recommend you use StackOverflow to uncover what you need to do.

The Intel XDK creates standard Cordova CLI applications. So you need to search for Cordova app solutions that relevant to your issue. What you find there will work with the XDK, but only if the solution does not require that you modify things like the AndroidManifest.xml file. If you have to implement that sort of solution (which is quite common for these sorts of problems) you'll have to use Cordova CLI directly. Our cloud-based build system limits your flexibility, which is the tradeoff for the convenience it offers.

0 Kudos
Reply