1.0.0 • Published 2 years ago

@fdagreat/capacitor-firebase-dynamic-links v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@fdagreat/capacitor-firebase-dynamic-links

npm version

Capacitor plugin for Firebase Dynamic Links

Configuration

Android

In file android/app/src/main/java/**/**/MainActivity.java, add the plugin to the initialization list:

import com.fdagreat.firebase.dynamiclinks.CapacitorFirebaseDynamicLinks;

public class MainActivity extends BridgeActivity {
   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      ...
      registerPlugin(CapacitorFirebaseDynamicLinks.class);
   }
}

For advanced options please refer https://firebase.google.com/docs/dynamic-links/android/create

iOS

Configure your app to use dynamic links based on the official Firebase documentation. You need to apply the following three steps for iOS. They should be the same as the first three steps of the official Firebase documentation.

  1. In the Info tab of your app's Xcode project, create a new URL type to be used for Dynamic Links. Set the Identifier field to a unique value and the URL scheme field to be your bundle identifier, which is the default URL scheme used by Dynamic Links.
  2. In the Capabilities tab of your app's Xcode project, enable Associated Domains and add the following to the Associated Domains list:
applinks:your_dynamic_links_domain
  1. If you want to receive Dynamic Links with a fully-custom domain, in your Xcode project's Info.plist file, create a key called FirebaseDynamicLinksCustomDomains and set it to your app's Dynamic Links URL prefixes. For example:
FirebaseDynamicLinksCustomDomains
    https://example.com/promos
    https://example.com/links/share

Web

None

Example

import {
  FirebaseDynamicLinks,
  LinkConfig,
} from '@fdagreat/capacitor-firebase-dynamic-links';

function createShortLink(): Promise<string> {
   const config: LinkConfig = {
      domainUriPrefix: 'https://example.page.link',
      uri: 'https://example.page.link/sharing',
   };
   return FirebaseDynamicLinks.createShortLink(config).then(link => link.value);
}

function listenToDeepLinkOpen() {
   FirebaseDynamicLinks.addListener('deepLinkOpen', (data) => {
       console.log(data);
   });
}

API

addListener('deepLinkOpen', ...)

addListener(eventName: 'deepLinkOpen', listenerFunc: (data: DeepLinkOpen) => void) => PluginListenerHandle

Adds a listener to the opening of a dynamic link

ParamTypeDescription
eventName'deepLinkOpen''deepLinkOpen' for listening to open links
listenerFunc(data: DeepLinkOpen) => voidCallback function to be called when the event is fired

Returns: PluginListenerHandle


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all native listeners for this plugin


createDynamicLink(...)

createDynamicLink(linkConfiguration: LinkConfig) => Promise<{ value: string; }>

Creates a new dynamic Link based on the configuration

ParamTypeDescription
linkConfigurationLinkConfigconfiguration for the link

Returns: Promise<{ value: string; }>


createDynamicShortLink(...)

createDynamicShortLink(linkConfiguration: LinkConfig) => Promise<{ value: string; }>

Creates a new short dynamic link based on the configuration. Its basically a shortened version of the dynamic link. *

ParamTypeDescription
linkConfigurationLinkConfigconfiguration for the link

Returns: Promise<{ value: string; }>


Interfaces

PluginListenerHandle

PropType
remove() => Promise<void>

DeepLinkOpen

PropTypeDescription
urlstringThe URL that was opened

LinkConfig

PropTypeDescription
uristringThe link your app will open.
domainUriPrefixstringYour Dynamic Link URL prefix, which you can find in the Firebase console. A Dynamic Link domain looks like the following: https://example.page.link.
androidParametersAndroidParametersAndroid specific configuration
iosParametersIOSParametersiOS specific configuration
navigationInfoNavigationInfoParametersAdditional parameters for the navigation of the app.
socialMetaSocialMetaTagParametersConfiguration for showed data when sharing the link with social media.
googleAnalyticsGoogleAnalyticsParametersGoogle Play analytics paremeters
iTunesConnectAnalyticsItunesConnectAnalyticsParametersiTunes Connect analytics parameters
webApiKeystringFirebase Web Api key

AndroidParameters

PropTypeDescription
packageNamestringYour bundle ID (e.g. com.example.android)
fallbackUrlstringThe link to open when the app isn't installed. Specify this to do something other than install your app from the Play Store when the app isn't installed, such as open the mobile web version of the content, or display a promotional page for your app.
minimumVersionnumberThe versionCode of the minimum version of your app that can open the link. If the installed app is an older version, the user is taken to the Play Store to upgrade the app.

IOSParameters

PropTypeDescription
bundleIdstringYour bundle ID (e.g. com.example.android)
appStoreIdstringYour app's App Store ID, used to send users to the App Store when the app isn't installed
fallbackUrlstringThe link to open when the app isn't installed. Specify this to do something other than install your app from the App Store when the app isn't installed, such as open the mobile web version of the content, or display a promotional page for your app.
customSchemestringYour app's custom URL scheme, if defined to be something other than your app's bundle ID
ipadFallbackUrlstringThe link to open on iPads when the app isn't installed. Specify this to do something other than install your app from the App Store when the app isn't installed, such as open the web version of the content, or display a promotional page for your app.
ipadBundleIdstringThe bundle ID of the iOS app to use on iPads to open the link. The app must be connected to your project from the Overview page of the Firebase console.
minimumVersionstringThe version number of the minimum version of your app that can open the link. This flag is passed to your app when it is opened, and your app must decide what to do with it.

NavigationInfoParameters

PropTypeDescription
forcedRedirectEnabledbooleanIf set to true, skip the app preview page when the Dynamic Link is opened, and instead redirect to the app or store. The app preview page (enabled by default) can more reliably send users to the most appropriate destination when they open Dynamic Links in apps; however, if you expect a Dynamic Link to be opened only in apps that can open Dynamic Links reliably without this page, you can disable it with this parameter. This parameter will affect the behavior of the Dynamic Link only on iOS.

SocialMetaTagParameters

PropTypeDescription
titlestringThe title to use when the Dynamic Link is shared in a social post.
descriptionstringThe description to use when the Dynamic Link is shared in a social post.
imageUrlstringThe URL to an image related to this link. The image should be at least 300x200 px, and less than 300 KB.

GoogleAnalyticsParameters

PropTypeDescription
sourcestringSets utm_source
mediumstringSets utm_medium
campaignstringSets utm_campaign
termstringSets utm_term
contentstringSets utm_content

ItunesConnectAnalyticsParameters

PropTypeDescription
providerTokenstringSets pt
affiliateTokenstringSets at
campaignTokenstringSets ct
1.0.0

2 years ago