Search code examples
firebasecordovaionic-frameworkfirebase-dynamic-links

How do I use cordova firebase.dynamiclinks plugin in Ionic 4?


I want to use Cordova Firebase Dynamiclinks plugin : https://github.com/chemerisuk/cordova-plugin-firebase-dynamiclinks#installation in my Ionic 4 App.

There is an Ionic-native-plugin usage for this too : npm install @ionic-native/firebase-dynamic-links and usage :

import { FirebaseDynamicLinks } from '@ionic-native/firebase-dynamic-links/ngx';

constructor(private firebaseDynamicLinks: FirebaseDynamicLinks) { }

...
this.firebaseDynamicLinks.onDynamicLink()
  .subscribe((res: any) => console.log(res), (error:any) => console.log(error));

Issue is : I want to use createDynamicLink(parameters) method available in Cordova Firebase Dynamiclinks plugin but Ionic-native-plugin says

Property 'createDynamicLink' does not exist on type 'FirebaseDynamicLinks'.

Therefore, I need to use Cordova Firebase Dynamiclinks directly and I tried doing using it like

import { cordova } from '@ionic-native/core';
...
cordova.plugins.firebase.dynamiclinks.createDynamicLink({
    link: "https://google.com"
}).then(function(url) {
    console.log("Dynamic link was created:", url);
}); 

But got error

Property 'plugins' does not exist on type '(pluginObj: any, methodName: string, config: CordovaOptions, args: IArguments | any[]) => any'.

Also tried removing import

cordova.plugins.firebase.dynamiclinks.createDynamicLink({
    link: "https://google.com"
}).then(function(url) {
    console.log("Dynamic link was created:", url);
});

And got this

Property 'firebase' does not exist on type 'CordovaPlugins'.

What is the correct usage of cordova plugins?

Update

Ionic-native-plugin now contains all the methods available in Cordova Firebase Dynamiclinks plugin.


Solution

  • I believe this is more fitting of a comment, but I don't quite have the reputation for it yet.

    Currently, there is a PR open in the @ionic-team/ionic-native repo (here). This exposes the extra methods, but until then you can use the original repo here to get your desired effect. In order to install the repo you will have to follow the directions in the Developer guide here. Cheers!