[SalesForce] How to Deeplink FSL mobile App and Salesforce App

I have been struggling a bit to find the right documentation to accomplish a seemingly easy task.

Deeplinking: FSL App to Salesforce App

Now for starters, I have found a very easy way to deep link the FSL app to the Salesforce app:

  1. Go to Field Service Mobile Settings>App Extensions, and add an App Extension.
  2. Simple enter in the values as given below.
    The bottom example works for android, and made a similar one with type iOS:
    enter image description here

And its that easy. Once you go into your FSL app, these app extensions will redirct you to the Salesforce App. Now for the reverse, which is not so easy…

Deeplinking: Saleforce App to FSL App

So this is a little trickier…requires a global action…

  1. Create a visualforce page, called Open_FSL

    <apex:page controller="Open_FSL" action="{!urlRedirection}" > </apex:page>

  2. Create an Apex Class for this page:

    public class Open_FSL {
    public PageReference urlRedirection()
    { string url = 'com.salesforce.fieldservice://v1/sObject/';
    PageReference page = new PageReference(url);
    page.setRedirect(true); return page; }
    }
    Now pay close attention to the string url = 'com.salesforce.fieldservice://v1/sObject/'

this comes directly from Salesforce FSL URI schema here:

https://developer.salesforce.com/docs/atlas.en-us.220.0.field_service_dev.meta/field_service_dev/fsl_dev_mobile_deep_linking_schema.htm

Which says it works for both iOS and Android. More on this soon.
3) Create a custom Global Action
Basically you want to look at your visual force page with this global action: Now with Custom actions, you must also add your custom action to the Publisher Layout, and make sure that the "Available for Lightning, Mobile, etc." is checked on the Visualforce page.

And Hooray! You now can deep link back to your FSL app by pressing this Global Action…but only on Android. Once I was able to ask a work buddy to try it on iOS, an error appears:
"You can't view this page, either because you don't have permission or because the page isn't supported on mobile devices."

And here are some extra links to docs on this, in case someone finds this question in the future:

https://resources.docs.salesforce.com/sfdc/pdf/salesforce1_url_schemes.pdf

https://trailblazers.salesforce.com/sfc/servlet.shepherd/version/download/06830000004HnPU?asPdf=false&operationContext=CHATTER

But despite looking all over these docs, I am still not sure I get it…
So no love for iOS? I digged a bit deeper, and Apple likes to use what is called "Universal Links". And the documentation for Salesforce and Universal Links is limited, but it seems instead of using the "Salesforce1://" or in the case of FSL, "com.salesforce.fieldservice://v1/sObject/", which works perfectly for Android, we need to add https:// for Universal Links. So trying "https://com.salesforce.fieldservice://v1/sObject/", well Android doesnt like it, and iOS still isnt working properly.
So now to my Question:
What am I missing? Does anyone have a good example using iOS with Salesforce Deeplinking? Do I need to have the apex class look to 2 different addresses in order to have it work for both Android and iOS? based off the Salesforce1 for iOS Mobile schemes document, why doesnt my https address work? Has anyone else done this? Any hints, tidbits, or overall solutions would be greatly appreciated.

Best Answer

Well, it looks like I may have answered ny own question. Basically the problem is visualforce, from what I could gather. According to this document right here: https://help.salesforce.com/articleView?id=000320409&language=en_US&mode=1&sfdcIFrameOrigin=null&type=1

So I expermented with an LWC to start to see if we could not get it to work there:

openFSL.html

<template>
<lightning-card title = "Open FSL App">
<lightning-button
 label="CONFIRM" 
 onclick={navigateToWebPage}></lightning-button></lightning-card></template>

openFSL.js

import { LightningElement } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
export default class OpenFSL extends NavigationMixin(LightningElement) {
// Navigation to web page 
navigateToWebPage() {
    this[NavigationMixin.Navigate]({
        "type": "standard__webPage",
        "attributes": {
            "url": "com.salesforce.fieldservice://v1/sObject/"
        }
    });
} 
}

openFSL.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>49.0</apiVersion>
<isExposed>true</isExposed>
<targets>
    <target>lightning__AppPage</target>
</targets>
</LightningComponentBundle>

And low and behold, that worked! Problem is, I wanted this to be a Global Action, and LWCs are not supported with global actions. So I built an Aura Component which can be used with global actions! For newbies like me, go to: Developer Console>File>New>Lightning Component>Lightning Quick Action Give it a name like Open FSL, and add the below lines of code to the .cmp and .js files:

Open_FSL.cmp

<aura:component implements="force:lightningQuickAction" >
<aura:handler name="init" value="{!this}" action="{!c.redirect}"></aura:handler>
<lightning:navigation aura:id="navService"/>    
</aura:component>

OpenFSLController.js

({
redirect : function(component, event, helper) {
    let pageReference = {
        type: 'standard__webPage',
        attributes: {
            url: 'com.salesforce.fieldservice://v1/sObject/'
        }
    };
    let navService = component.find('navService');
    navService.navigate(pageReference);
}
})

And there you go, a few modern solutions for dealing with deep links and FSL and Salesforce1. I also experimented with some other apps like google maps and google earth, and these also work! Eventually I will be needing to get to specific records and/or coordinates, so I will post my finds here on that as well.

Related Topic