hypery2k / nativescript-urlhandler

NativeScript URL Handler Plugin
MIT License
52 stars 34 forks source link

The plugin doesn't work on iOS #88

Open meysam-mahmoodi opened 5 years ago

meysam-mahmoodi commented 5 years ago

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);
        });
    }
 }
hypery2k commented 5 years ago

which version of the plugin you'r using?

hypery2k commented 5 years ago

can you try version 1.3.0?

meysam-mahmoodi commented 5 years ago

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.

blaur commented 5 years ago

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

blaur commented 5 years ago

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"
  },
RickyLarsen commented 5 years ago

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.

NL33 commented 5 years ago

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.

hypery2k commented 5 years ago

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

NL33 commented 5 years ago

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 commented 5 years ago

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

farfromrefug commented 4 years ago

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

hypery2k commented 4 years ago

and to whom I should handover it?

farfromrefug commented 4 years ago

Me I will maintain it add contributors if they want

daweedm commented 4 years ago

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

daweedm commented 4 years ago

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.

keithgulbro commented 4 years ago

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.

tobiasklemp commented 4 years ago

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.

asharghi commented 4 years ago

Any solution to this?

farfromrefug commented 4 years ago

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

asharghi commented 4 years ago

Nice. Want to create a PR to this repo?

farfromrefug commented 4 years ago

@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!

mikykonst commented 4 years ago

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

farfromrefug commented 4 years ago

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

mikykonst commented 4 years ago

@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" } }

farfromrefug commented 4 years ago

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

mohammadrafigh commented 3 years ago

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.