nativescript-urlhandler icon indicating copy to clipboard operation
nativescript-urlhandler copied to clipboard

The plugin doesn't work on iOS

Open meysam-mahmoodi opened this issue 6 years ago • 26 comments
trafficstars

Hello

What did you do?

I installed the plugin successfully then created my own URL Scheme. When I type my own URL Scheme in a browser, it goes to the app correctly but handleOpenURL method is not called and I can't get anything.

What did you expect to happen?

I expected, handleOpenURL ran and I can get the App URL in App Component.

What happened instead?

The method,handleOpenURL, was not raised.

Your Environment

NativeScript version: 5.4.0 Java version: NodeJS and NPM version: NodeJS: v8.9.1 Platform(s) running: iPhone 6s iOS 12.3.1

Demo Project

N/A

app.component

import { Component, OnInit } from "@angular/core";
import { NavigationEnd, Router } from "@angular/router";
import { AppURL, handleOpenURL } from "nativescript-urlhandler";

@Component({
    moduleId: module.id,
    selector: "ns-app",
    templateUrl: "app.component.html",
})

export class AppComponent implements OnInit {
    constructor(
        private router: Router,
    ) {}

    public ngOnInit() {
        handleOpenURL((appURL: AppURL) => {
            console.log("Got the following appURL", appURL);
        });
    }
 }

meysam-mahmoodi avatar Jun 19 '19 06:06 meysam-mahmoodi

which version of the plugin you'r using?

hypery2k avatar Jun 19 '19 06:06 hypery2k

can you try version 1.3.0?

hypery2k avatar Jun 19 '19 15:06 hypery2k

Thank you for your answer. I tried that with version 1.3.0. It doesn't work. After a few hours, I still could not understand what the problem is.

meysam-mahmoodi avatar Jun 22 '19 07:06 meysam-mahmoodi

@hypery2k I'm having the same problem on most recent version of Nativescript.

blaur avatar Jul 12 '19 14:07 blaur

Don't know if this helps you but my package.json looks like this. All working on android but on iOS it just does not do anything:

 "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/http": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "nativescript-angular": "~7.2.0",
    "nativescript-mobilepay": "file:../src",
    "nativescript-theme-core": "~1.0.4",
    "reflect-metadata": "~0.1.12",
    "rxjs": "~6.3.0",
    "tns-core-modules": "~5.3.0",
    "zone.js": "~0.8.26",
     "nativescript-urlhandler": "^1.3.0"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~7.2.0",
    "@nativescript/schematics": "~0.5.0",
    "@ngtools/webpack": "~7.2.0",
    "nativescript-dev-typescript": "~0.9.0",
    "nativescript-dev-webpack": "~0.21.0"
  },

blaur avatar Jul 13 '19 16:07 blaur

I'm getting the same behavior. I'm not even seeing the "No callback provided. Please ensure that you called "handleOpenURL" during application init!" error message.

RickyLarsen avatar Aug 02 '19 15:08 RickyLarsen

Any update on this? I am trying to use the plugin to register universal links on iOS, and, after putting in the code from the docs, nothing happens.

NL33 avatar Sep 23 '19 19:09 NL33

sorry to say but have to quit the plugin as I don't have time to support it.

hypery2k avatar Sep 23 '19 19:09 hypery2k

Wow. Is there an older plugin version that works with iOS for universal links? There is a stack overflow question here that implies someone was able to use it for universal links a year ago.

NL33 avatar Sep 23 '19 19:09 NL33

If you are looking to handle universal links, see the code in this stack overflow answer. This code does not require this plugin.

NL33 avatar Sep 24 '19 20:09 NL33

@hypery2k please can you pass the ownership of the plug-in? Especially the npm package. Thanks

farfromrefug avatar Dec 10 '19 22:12 farfromrefug

and to whom I should handover it?

hypery2k avatar Dec 11 '19 02:12 hypery2k

Me I will maintain it add contributors if they want

farfromrefug avatar Dec 11 '19 07:12 farfromrefug

Hello everyone, does anyone has a quick fix for this issue ?

daweedm avatar Dec 20 '19 08:12 daweedm

For anyone that would be still stuck with this : the plugin is working, even with iOS 13. The problem is related to plugins conflicts. In my case, for instance, it was related to nativescript-plugin-firebase, which overrides the "UIApplicationDelegate" to insert its own callback. Both nativescript-plugin-firebase and this plugins uses the same approach to catch the "open app from url" event. The plugins maintainers should align themselves and find a way to listen for AppDelegate events without conflicting with each others. The same problem occurs with the nativescript-facebook plugin.

daweedm avatar Jan 02 '20 20:01 daweedm

Any update on this? @daweedm makes a solid point. Many Nativescript plugins overwrite the iOS app delegate instead of allowing those methods to be called once the plugin is imported.

If the methods could be called inside of a iOS app delegate created by the app's developer, this functionality wouldn't conflict with other plugins.

keithgulbro avatar Apr 14 '20 20:04 keithgulbro

Maybe the function handleOpenURL should hand through all of the parameters it gets from the delegate on ios. Then it would be possible to use this plugin whenever a custom app delegate is needed and even could be a peer dependency for plugins that require custom delegates.

tobiasklemp avatar Apr 29 '20 12:04 tobiasklemp

Any solution to this?

asharghi avatar Jul 28 '20 00:07 asharghi

Yes i wrote a new component for that . not in front of my computer but it should be nativescript-appurl

farfromrefug avatar Jul 28 '20 05:07 farfromrefug

Nice. Want to create a PR to this repo?

asharghi avatar Jul 28 '20 09:07 asharghi

@asharghi i wont. This plugin is not maintained anymore. I decided to go and maintain my own. You decide which one you want to use!

farfromrefug avatar Jul 28 '20 09:07 farfromrefug

@farfromrefug your plugin is not working with IOS too. Its working on debug but on release callback not working. Any solutions?

mikykonst avatar Aug 13 '20 11:08 mikykonst

@mikykonst no idea wreally. Works perfectly here in production. Must be related to your itunesconnect configs.

farfromrefug avatar Aug 13 '20 13:08 farfromrefug

@farfromrefug May it me an issue with nativescript version?

{ "name": "MyApp", "license": "SEE LICENSE", "version": "0.0.0", "nativescript": { "id": "com.MyApp", "tns-android": { "version": "6.1.0" }, "tns-ios": { "version": "6.1.0" } }, "dependencies": { "@angular/animations": "~8.0.1", "@angular/common": "~8.0.1", "@angular/compiler": "~8.0.1", "@angular/core": "~8.0.1", "@angular/forms": "~8.0.1", "@angular/http": "~8.0.0-beta.10", "@angular/platform-browser": "~8.0.1", "@angular/platform-browser-dynamic": "~8.0.1", "@angular/router": "~8.0.1", "@nativescript/core": "^6.5.15", "@nstudio/nativescript-checkbox": "^1.0.0", "compare-versions": "^3.6.0", "crypto-js": "3.3.0", "font-awesome": "^4.7.0", "moment": "^2.27.0", "nativescript-angular": "~8.0.1", "nativescript-appurl": "^1.3.5", "nativescript-appversion": "^1.4.4", "nativescript-camera": "^4.5.0", "nativescript-contacts-lite": "^0.2.7", "nativescript-drop-down": "^5.0.6", "nativescript-http-formdata": "^1.7.0", "nativescript-imagepicker": "^7.1.0", "nativescript-iqkeyboardmanager": "^1.5.1", "nativescript-localize": "^4.2.1", "nativescript-mediafilepicker": "^3.0.1", "nativescript-microsoft-appcenter": "^2.0.0", "nativescript-permissions": "^1.3.9", "nativescript-secure-storage": "^2.6.1", "nativescript-theme-core": "~1.0.4", "nativescript-ui-listview": "^7.0.5", "nativescript-ui-sidedrawer": "^7.0.4", "nativescript-unit-test-runner": "^0.7.0", "reflect-metadata": "~0.1.13", "rxjs": "^6.5.5", "tns-core-modules": "^6.2.0", "zone.js": "~0.9.1" }, "devDependencies": { "@angular-devkit/core": "~8.0.1", "@angular/cli": "~8.0.3", "@angular/compiler-cli": "~8.0.1", "@nativescript/schematics": "^0.7.3", "@ngtools/webpack": "~8.0.3", "@types/faker": "^4.1.12", "@types/jasmine": "3.3.16", "faker": "^4.1.0", "karma": "4.3.0", "karma-jasmine": "2.0.1", "karma-nativescript-launcher": "0.4.0", "karma-webpack": "3.0.5", "nativescript-dev-webpack": "^1.3.0", "node-sass": "^4.14.1", "tns-platform-declarations": "^6.5.15", "tslint": "^5.20.1", "typescript": "~3.4.3" } }

mikykonst avatar Aug 13 '20 13:08 mikykonst

@mikykonst i dont think so. I really thing it is an issue with your itunes config

farfromrefug avatar Aug 13 '20 15:08 farfromrefug

Just as a side note, my own problem was that I didn't set LSApplicationQueriesSchemes in info.plist of the source app (the app I'm trying to link from). It seems this key is required from iOS 9. After setting this key the forked version of @farfromrefug worked well. LSApplicationQueriesSchemes should be an Array with an item being your custom schema.

Reference: https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl?language=objc. Note the Important notice under Discussion.

mohammadrafigh avatar May 11 '21 23:05 mohammadrafigh