[SOLVED]How to set up Deep Links with iOS?


#1

Im trying to get Deep Links to work in my iOS, phonegap build app.

I have included the “cordova-universal-links-plugin” plugin and in my config I have this.

<plugin name="cordova-universal-links-plugin" source="npm" />
<universal-links>
    <host name="manmade.se" scheme="manmade" event="ul_myExampleEvent" />
</universal-links>

I have created a apple-app-site-association file and uploaded it to my server in the root. And it works.

{
  "activitycontinuation": {
    "apps": [
      "myappid.se.manmade.appname"
    ]
  },
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "myappid.se.manmade.appname",
                "paths": [ "/manmade/*" ]
            },
            {
                "appID": "myappid.se.mydomain.appname",
                "paths": [ "*" ]
            }
        ]
    }
}

And I have set “Associated Domains” in my AppId before I downloaded the provision.profile

And in my index.html file I have this eventlistner.

universalLinks.subscribe('ul_myExampleEvent', function (eventData) {
				// do some work
				// in eventData you'll see url и and parsed url with schema, host, path and arguments
				console.log('Did launch application from the link: ' + JSON.stringify(eventData));
				alert('Did launch application from the link 1: ' + JSON.stringify(eventData));
			});

And as far as I understand this is all I have to do to make Deep links to work, så when I click on a https://manmade.se link in my iPhone it should open it in my app!??

So has anybody done this before? I don´t know what Im missing.
I get no error anywhere, but it is not firing the “ul_myExampleEvent” or anything else.

So any input really appreciated, thanks.


#2

Your question is more about Phonegap Build, and not so much about Framework 7. I’d advise asking the question on https://stackoverflow.com instead.


#3

@Manmade it won’t work with PhoneGap build, because this plugin uses some own cordova hooks to add entitlements to app package. And PhoneGap Build doesn’t allow custom hooks due to security reasons. Had same problem with one of my clients app. And we had to move from PhoneGap build because of such issues to manual cordova build


#4

Ok, thank you SOOO much!! I have been trying to get it to work for 2 days now haha.

It is strange since I see this in the build log file:
Entitlements:

{
    "application-identifier" = "7MP323UK6C.se.manmade.mobilrex";
    "aps-environment" = development;
    "com.apple.developer.associated-domains" = "*";
    "com.apple.developer.team-identifier" = 7MP323UK6C;
    "get-task-allow" = 1;
}

So I thought that it would work.
But I guess I have to learn how to do it with the ordinary phonegap instead.
Thanks again.


#5

So I need to package it with the terminal when the app is finished? I can’t create it with the phonegap GUI and then package it with phonegap.build? Just want to be sure. Thanks, Vladimir.
Since I have only build with phone gap.build before and there I scan a QR code to install the app on my phone.

With this, do I have to upload the ipa file on my server and the surf to it, to install it or how do you install it?
Thanks again.


#6

Yes, you can package it for Android using cordova cli http://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html or Android Studio. For building iOS app you need to use XCode, setup there provisioning profiles and certificates. To deploy it to your device you can attach phone to mac and do it from XCode or using TestFlight from iTunes Connect


#7

Thanks, Vladimir. But please, please help me again, this is my fifth day trying to get deep linking to work.

I have finally set up and build my app with cordova and then built it with xcode to my iPhone 4S, and when I try to send a push notification with pushwoosh.com and sending a deep link from there it still is not firing the “ul_myExampleEvent” event?

I don´t know what Im missing?

In my .js file I have this.

 universalLinks.subscribe('ul_myExampleEvent', function (eventData) {
      // in eventData you'll see url и and parsed url with schema, host, path and arguments
      alert('Did launch application from the link2: ' + JSON.stringify(eventData));
 });

I have added the plugins to my project/ config file via the terminal.

    <plugin name="pushwoosh-cordova-plugin" spec="^7.0.6">
            <variable name="LOG_LEVEL" value="DEBUG" />
            <variable name="IOS_FOREGROUND_ALERT_TYPE" value="NONE" />
            <variable name="ANDROID_FOREGROUND_PUSH" value="false" />
     </plugin>

    <plugin name="cordova-universal-links-plugin" spec="^1.2.1" />
    <universal-links>
            <host name="manmade.se" scheme="https" event="ul_myExampleEvent" />
    </universal-links>

I have in Xcode added the Associated Domains “applinks:manmade.se

I have uploaded the apple-app-site-association file to my server.

And on pushwoosh.com it says it should work out off the box haha…
https://www.pushwoosh.com/v1.0/docs/deep-linking

Then I have tried to send push notifications in a couple off ways, but none off them fires the event “ul_myExampleEvent”.

If I send a push with this deep link it opens in Safari.
https://manmade.se/manmade/features.asp - this opens the page in Safari

And if I hold on the same link in the note app then I get the choice “Open in my app” and “Open in Safari” so I guess that Universal links are working as then should in the app? But why isn´t the event firing when I send a push? Any ideas?

I really hope you can help since I understood that you have done this before.
Thanks a lot! Vladimir.


#8

To be honest don’t know what is the problem with push notifications, didn’t work with push woosh and UL from notifications. I used direct links which works fine for me. Here is what i have in config.xml, where XXX and YYY are actual values:

<plugin name="cordova-universal-links-plugin" spec="https://github.com/flipflopapp/cordova-universal-links-plugin" />
    <universal-links>
      <host name="XXX" event="deeplink">
        <path url="*" />
      </host>
      <ios-team-id value="YYY" />
    </universal-links>

this is what i have in entitlements:

<dict>
	<key>aps-environment</key>
	<string>development</string>
	<key>com.apple.developer.associated-domains</key>
	<array>
		<string>applinks:XXX</string>
	</array>
</dict>

And JS:

window.universalLinks.subscribe('deeplink', (eventData) => {
      const { path, params } = eventData;

      const query = Object.keys(params)
        .map(key => `${key}=${params[key]}`)
        .join('&');

      const url = `${path}/${query.length ? `?${query}` : ''}`.replace('//', '/');

      UniversalLinks.handle(url);
    });

where UniversalLinks.handle(url); method to load required route


#9

Ok, thanks a lot Vladimir. But it looks the same as I have tested Im afraid.
The only thing is with the “window.” that I don´t have tested, is that really necessary you think?

That was a framework7 app I guess?
With “where UniversalLinks.handle(url); method to load required route” you mean that it loads the framework7 route? I normally only do framework7 apps but with this one I only load a responsive webshop from the server.
But very good to know how to do it with framework7 apps, so thanks again for your help.


#10

No, it is not neccessary

yes

Yeah, it is just define which page to load by F7 router depending on requested UL url


#11

Thanks, Vladimir. It turned out that pushwoosh had some reference to an old plugin that did´t work at all now. So I spend 5 days trying to get something to work that did´t work from the beginning haha.
And I only care about deep links, not universal links, since I only use it when sending pushes.

So now to get deep links to work with pushwoosh.com and phonegap.build I use this plugin.

<gap:plugin name="cordova-plugin-customurlscheme" source="npm">
<param name="URL_SCHEME" value="something" />
</gap:plugin>

And then the deep links when sending pushes from pushwoosh looks like this

something://http://yourdomain.com/page.asp?id=123

If anybody else might need it.

Again, thanks Vladimir.