Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This section, we will describe the discoveries about deep link on Salesforce In-app Message.

Android

  • We will need to create a Java class to call via React as a lib;

  • Then, our class will need to extend Plugin and implements MarketingCloudSdk.InitializationListener, also this class will be assign with: @NativePlugin()

  • Therefore, we will need to implements three methods, then firsts two methods load and complete that will be able empty and will be assign @Override;

  • The others method we will need to add a some codes:

    • The first method that will be a main method is: public void initialize(final PluginCall call) it’s very important this method be named initialize, 'cause the React will call it. This methods will assign with @PluginMethod() like this:

  • Until this moment the call InAppMessageListener.INSTANCE no exist, so we will need to create an enum to satisfy it;

  • Then, will be create a enum InAppMessageListener that implements UrlHandler

    • We will instance the constant INSTANCE;

    • Inside this enum, will create a methods PendingIntent handleUrl() that when the user clicked on in-app action button with link, this method will intercept the action and run.

      • So, we need to treat the link to open the app or open the browser, like that:

    • Lastly, the class need to imported on MainActivity class, like that:

    • As the react code will call the initialize method, the feature will works just on market that the react call run;

IOS

  • At the moment to IOS, didn’t discovery anything code that works when the user clicks on salesforce in-app message.

    • What we know?

      • We need to intercept the click, but the click is only intercepted in the code of the step that we cannot change to redirect the user, because the code snippet is in an installed lib that cannot be changed;

      • The click is trigged on method sfmc_handleURL from MCCordovaPlugin

      • The code need the same main method initialize to satisfy the react call, like that:

REACT

  • With all codes created, now we will call the initialize method on React, so we will create a file to export the library that we created

    • We will to to import the Plugins from @capacitor/core

    • Create an interface that contains our main method initialize()

    • Register the Android and IOS classes on capacitor, using the Plugins method imported

    • Export the code

    • Now, the code is ready to called

  • No labels