Links not working on iPhone 5C

43 views Asked by At

So, I'm at a conference, and we ran through a talk on NativeScript. Thought it was super-nifty, and I really enjoyed it. I am not/have not been into mobile dev before.

I found an interesting bug, however. We worked on an app that pulled data from the SpaceX API. The individual view has links to the rocket launches that you can tap on to open them in-browser. Unfortunately, that does not work on my iPhone 5C. The presenter scanned my QR code, and was able to click the links just fine. Anyone seen this before/know a workaround?

Here's the offending code:

HTML:

<Label text="{{ 'Video: ' + launch.links.video_link }}" class="body m-l-20 m-r-20 m-t-20" textWrap="true" (tap)="onLinkTap(launch.links.video_link)">
</Label>

JS:

onLinkTap(link: string): void {
    utils.openUrl(link);
}
1

There are 1 answers

0
Nick Iliev On

By default, on iOS, we would need to set CFBundleURLTypes in info.plist and provide applicationHnadleOpenUrl delegate method.

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>com.yourcompany.myapp</string>
    </dict>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>myapp</string>
        </array>
    </dict>
</array>

And sample implementation of the delegate method

function getParams(url){
    console.log(url);
    var resulturl:string = (<any>NSString)(url).toString();;
    if(resulturl.substring(0,5)=="appgo"){
       console.log(getParameterByName("test", resulturl));
    }

}


class newIOSApplication extends NSObject implements UIApplicationDelegate{
static ObjCProtocols = [UIApplicationDelegate];
        applicationHandleOpenURL(app, url): boolean {
            getParams(url);
            return true;
        }
}
application.ios.delegate = newIOSApplication;

More about the above code here. There is also this community plugin that handles the delegate method for your