Software Archive
Read-only legacy content
17061 Discussions

iOS Universal Links

Keith_T_
Beginner
656 Views

I've been banging my head against the wall trying to get Universal Links to work with the Intel XDK for the iOS build.

I found this plugin, but it does not appear to work with the Intel XDK due to JS hooks restrictions for security reasons.

https://github.com/nordnet/cordova-universal-links-plugin

After reading through several dozen articles and sites trying to figure the process out, it seems like the one element missing is adding the website domain.

On this site, they describe doing this by "Setting app capabilities in Xcode".

https://medium.com/@barsh/my-first-date-with-ios-universal-links-90dfabc88bb8#.nw1sioaut

From other reading, it seems that this is essentially adding the following information to the Entitlements.plist file in the iOS App .ipa file.

<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>activitycontinuation:extrasolar.com</string>
<string>applinks:extrasolar.com</string>
</array>
</dict>

Is there a way to do this in the Intel XDK? If I look at the build logs, I see this section which seems relevant:

ProcessProductPackaging /Applications/Xcode.app/Contents.../Platforms/iPhoneOS.platform.../SDKs/iPhoneOS9.2.sdk/Entitlements.plist build/Extrasolar.build/Release-iphoneos/Extrasolar.build/Extrasolar.app.xcent
    cd .../cordova_project/platforms/ios
    export PATH="/Applications/Xcode.app/Contents.../Platforms/iPhoneOS.platform.../usr/bin:/Applications/Xcode.app/Contents.../usr/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools:/platform-tools"
    builtin-productPackagingUtility /Applications/Xcode.app/Contents.../Platforms/iPhoneOS.platform.../SDKs/iPhoneOS9.2.sdk/Entitlements.plist -entitlements -format xml -o .../cordova_project/platforms/ios/build/Extrasolar.build/Release-iphoneos/Extrasolar.build/Extrasolar.app.xcent

CodeSign build/device/Extrasolar.app
    cd .../cordova_project/platforms/ios
    export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents.../Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    export PATH="/Applications/Xcode.app/Contents.../Platforms/iPhoneOS.platform.../usr/bin:/Applications/Xcode.app/Contents.../usr/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools:/platform-tools"
    
Signing Identity:     "iPhone Distribution: Lazy 8 Studios LLC (4DTA8BT86B)"
Provisioning Profile: "Adhoc Keith and Rob iPads 20160724"
                      (f13dc062-f668-4839-96cf-9fdb34e28ec4)

    /usr/bin/codesign --force --sign A9B4FE605826F11E1F12E5089AD816799B3198A3 --entitlements .../cordova_project/platforms/ios/build/Extrasolar.build/Release-iphoneos/Extrasolar.build/Extrasolar.app.xcent --timestamp=none .../cordova_project/platforms/ios/build/device/Extrasolar.app

Is it possible to create a plugin that will manipulate the Entitlements.plist file and add it to the project in the way I want, possibly by doing something like this in the plugin config.xml:

<config-file target="Entitlements.plist">

0 Kudos
9 Replies
PaulF_IntelCorp
Employee
656 Views

Keith -- you'd have to use something like the technique described here > https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#platform < which is described in more detail in the Cordova CLI specs:

Not sure how generic the mechanism is, but you might be able to make it work with that plist file. See the simple example of a plugin that consists of only a plugin.xml file in the FAQ. In other words, you create a custom one-file plugin, that consists of only the plugin.xml file, with the required Cordova CLI commands to make the changes, then add that as a local plugin to your project.

0 Kudos
Keith_T_
Beginner
656 Views

Paul -- I actually already tried that, and have read through those documents, here's a quick plugin I had created to test.

<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-intent-handler" version="0.0.1">
<name>Extrasolar.com Intent Handler</name>
<description>TODO</description>
<license>BSD-3</license>
<engines>
<engine name="cordova" version=">=3.0.0" />
</engines>
<platform name="ios">
<config-file target="Entitlements.plist" parent="/*">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>activitycontinuation:extrasolar.com</string>
<string>applinks:extrasolar.com</string>
</array>
</dict>
</config-file>
</platform>
</plugin>

I was able to use a similar method to add the Android Intent Filters to the AndroidManifest.xml file. It did not seem to work for iOS Entitlements.plist file, as you can see from the documentation you linked:

src(string) Required - Location of the file relative to plugin.xml. If the src file can't be found, the CLI stops and reverses the installation, issues a notification about the problem, and exits with a non-zero code.

When I open up the *.ipa file, there is no Entitlements.plist file, so if the file doesn't exist, I don't think you can modify or create it.

I believe you need similar Entitlements for doing iOS Push Notifications, if you look at the Feature Plugins section in the XDK, there are two Push Notification plugins listed, and they both say there are compatibility issues with them not working in the Intel XDK.

If you look at the build logs, you can see there is some Entitlements.plist file involved, it seems to be converting to Extrasolar.app.xcent, which seems to be some other format, this link might be relevant...

https://github.com/sotownsend/iarrogant

There seems to be a non-functional plugin that someone tried to write to handle adding Entitlements.plist through the Intel XDK, but seems to also be using JS hooks, and has a big warning indicating it did not work.

https://github.com/staxmanade/TestFlightBetaEntitlement

Here's the cordova specs for hooks, which as mentioned, do not work in the Intel XDK

https://cordova.apache.org/docs/en/latest/config_ref/#hook

For now, it seems like the only possible solution with the current Intel XDK builds is to do something like this and modify the build file, and re-sign it...

http://dev.mlsdigital.net/posts/how-to-resign-an-ios-app-from-external-developers/

In the future, it seems like two solutions that would work within Intel XDK are using a JS Hooks solution once that feature is added, or you need to create an empty Entitlements.plist that is included in the *.ipa build so that we can modify it with a plugin.

Is it possible I could include an Entitlements.plist file in the root of the app using an <intelxdk:> attribute in the intelxdk.config.additions.xml file? Is there one for adding a file? Or could I hack an existing one used for adding icons, or provision files to instead add the Entitlements.plist file?

Unless you have any other ideas, I'm giving up on solving this through the Intel XDK, and assuming it's currently not possible. Maybe you could hack the temp zip files that are uploaded to the build server to include an Entitlements.plist file

0 Kudos
PaulF_IntelCorp
Employee
656 Views

Keith -- based on that beta entitlements plugin you found, and the other info you cited, I would say "yes, I agree" it will not work with the current XDK build system. Because we don't include the "platform" part of the project in your XDK project directory, there is no where to place an entitlements.plist file in your project. Doing some sort of hack, like you described, with an <intelxdk: > preference tag is about the only way.

For implementation efficiency and maintenance reasons we're trying to minimize the use of special scripts and preference tags in the build system. So adding such a hack would not go over well. Thus, we're not likely to be able to support this feature until our build system is upgraded to support running hook scripts in our build system.

0 Kudos
Keith_T_
Beginner
656 Views

I wasn't able to include the file using preference tags, at least any of the ones I tried.

I'm trying some other solutions, and will update if any of them work.

After giving it some thought, from an engineering perspective, it seems like there really should be an option for including an Entitlements.plist file under the iOS Build Settings on the Projects tab. It's a pretty standard part of iOS applications, and the build process seems to already be looking for the file.

Supporting js hooks would be nice, but even then it seems like a workaround.

0 Kudos
PaulF_IntelCorp
Employee
656 Views

I'll talk to engineering about adding such a plist file.

0 Kudos
Keith_T_
Beginner
656 Views

I got Universal Links working for the Intel XDK iOS build, running in iOS 9.x

There are a lot of online blog posts with incomplete / misleading / outdated information, so here's a summary of what I did.

1. Have your signing certificate for iOS builds handy, I believe I downloaded mine from the Intel XDK user settings somewhere.

2. Set up apple-app-site-association on your website, you can view mine at https://extrasolar.com/apple-app-site-association

{
  "activitycontinuation": {
    "apps": [
      "4DTA8BT86B.com.lazy8studios.extrasolar.mobile"
    ]
  },
  "applinks": {
    "apps": [],
    "details": [{
        "appID": "4DTA8BT86B.com.lazy8studios.extrasolar.mobile",
        "paths": [ "*", "/" ]
      }]
  }
}

Serve it as 'content-type: application/json' MIME type. Do not encrypt it or sign it, as I believe that is an older standard.

3. Make sure your *.mobileprovision files include the permissions / entitlements for supporting Universal Links, I believe it's under a section called "Associated Domains". I also included permissions / entitlements for push notifications, and a few other features.

4. Create a Entitlements.plist file that includes the entitlements you need. This is the one I created.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>application-identifier</key>
    <string>4DTA8BT86B.com.lazy8studios.extrasolar.mobile</string>
    <key>aps-environment</key>
    <string>production</string>
    <key>get-task-allow</key>
    <false/>
    <key>keychain-access-groups</key>
    <array>
        <string>4DTA8BT86B.*</string>
    </array>
		<key>com.apple.developer.associated-domains</key>
		<array>
			<string>activitycontinuation:extrasolar.com</string>
			<string>activitycontinuation:www.extrasolar.com</string>
			<string>applinks:extrasolar.com</string>
			<string>applinks:www.extrasolar.com</string>
		</array>
		<key>com.apple.developer.team-identifier</key>
		<string>4DTA8BT86B</string>
		<key>beta-reports-active</key>
		<true/>
</dict>
</plist>

I could have probably used *.extrasolar.com to simplify things, but was being as explicit as possible to make sure everything worked.

5. Build your app for iOS using the Intel XDK and then download your *.ipa file.

6. Add the Entitlements.plist file you created to the *.ipa\Payload\Extrasolar.app\ path of your *.ipa file. I did this on Windows using 7zip, right clicking the file to open archive, and dragging the Entitlements.plist over to add it. Other methods probably work as well.

7. Use the iReSign app to resign your *.ipa file, you will need the signing certificate for iOS (step 1), the *.mobileprovision file (step 3), and the Entitlements.plist file (step 4). You do not need to change the app bundle ID. This post may be useful: http://dev.mlsdigital.net/posts/how-to-resign-an-ios-app-from-external-developers/

8. Upload your app to the Apple App Store Alpha or Beta, then download it to your device through Test Flight and cross your fingers. If everything works correctly, clicking on a link to your site in Safari (and other apps) in iOS should redirect and launch your app.

I have not tested this using adhoc provision files and directly installing to an iOS device, but it should work. Also, I didn't really explore passing data to the App through this method, although I believe it is possible.

Note to Intel Engineers: it would be really nice if you could include Entitlements.plist in the package-assets directory and have it added to the build, or if you could generate it from the entitlements listed in Info.plist (as they appear to be redundant) during the build.

If anyone needs help to get this working, feel free to contact me.

0 Kudos
PaulF_IntelCorp
Employee
656 Views

Keith -- I've already filed a feature request for the Entitlements.plist file. Thanks for the detailed workaround! :)

0 Kudos
Olga_V_
Beginner
656 Views

Hi!

I have some problem trying to resign my app: I've download the certificate from the apple developer site, clicked on it to add to keycahin assistant, but I don't see the certificate from the Resign app. How can I make resign see my certicate created with Intel XDK?

0 Kudos
PaulF_IntelCorp
Employee
656 Views

The certificate you created with the XDK is stored in the cloud, you have to download it using the XDK if you want your resign utility to see it. From the account (person) icon in the upper right of the XDK.

0 Kudos
Reply