Native mobile: deeplinks? applinks?

8
Has anyone implemented applinks with native mobile? like we did with phonegap (mycoolapp://<yourdeeplink...>) based on https://github.com/EddyVerbruggen/Custom-URL-scheme I would love to see this working with the new native mobile capability in Mendix, any experiences here?
asked
2 answers
2

This looks like a good place to starts: https://medium.com/react-native-training/deep-linking-your-react-native-app-d87c39a1ad5e

answered
0
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { Big } from "big.js";
import { Platform } from 'react-native'
import { Linking } from 'react-native'

// BEGIN EXTRA CODE
// END EXTRA CODE

/**
 * @param {string} url
 * @param {string} toolbarColor
 * @param {string} iosDismissButtonStyle
 * @param {string} androidShowTitle
 * @returns {Promise.<void>}
 */
export async function JA_LoginWithSSO(url, toolbarColor, iosDismissButtonStyle, androidShowTitle) {
	// BEGIN USER CODE
    // Documentation https://github.com/proyecto26/react-native-inappbrowser
	async function loadUserInfo() {
		const { navigation } = this.props
		const { state: { params } } = navigation
		const { code, error } = params || {}

		if (code) {
			console.warn("abcd1234 code ", code )
		// Get and Save the access token request, user info...
		}
		else {
		return Promise.reject(new Error(error))
		console.warn("abcd1234 reject error", error)
		}
	}
	const InAppBrowser = require("react-native-inappbrowser-reborn").default;
	const getDeepLink = (path = "") => {
		const scheme = 'xxxxxxxx'
		const tenant = 'xxxxxxxxx'
		const clientId = 'xxxxxxxx'
		const response_type = 'code'
		const prefix = `${scheme}://`
		return prefix + path
	}
	const deepLink = getDeepLink('callback');
  const weburl = `https://login.microsoftonline.com/${tenant}/oauth2/authorize?client_id=${clientId}&redirect_uri=${deepLink}&response_type=${responsetype}`;    

	const options = {
        toolbarColor,
        preferredBarTintColor: toolbarColor,
        dismissButtonStyle: iosDismissButtonStyle,
        showTitle: androidShowTitle
    };

	try {
		if (await InAppBrowser.isAvailable()){
      	console.warn('await completed')
				InAppBrowser.openAuth(weburl, deepLink, {
        // iOS Properties
				dismissButtonStyle: 'close',
				// Android Properties
				showTitle: false,
				enableUrlBarHiding: true,
				enableDefaultShare: true,
      	}
				).then((response) => {
			  	console.warn("abcd1234 response ", JSON.stringify(response));
			  	console.warn("abcd1234 response type " + response.type)
			  	return JSON.stringify(response);
        if (response.type === 'success' && 
          response.url) {
          Linking.openURL(response.url)
					(console.warn("abcd1234 response.url  ", response.url))
        }
      })
				console.warn("abcd1234 result ", result)
			} 
    } catch (error) {
      Linking.openURL(url)
			console.warn("abcd1234 url  ", url)
    }
	// END USER CODE
}

This works for me.  Obviously remove the logging before prod. The link will open the app directly, but still working on utilizing arguments with the return (tokens, etc).  Hope this gets you one step further.

answered