Important:
The Wix Navigate Mobile API contains functionality for navigating through your mobile app.
To use the Wix Navigate Mobile API, import wixNavigateMobile
from wix-navigate-mobile
module:
import wixNavigateMobile from "wix-navigate-mobile";
Mobile apps built on Wix use stack navigation. Stack navigation means that screens are arranged in a stack, so each new screen is placed on top of the previous screen, much like a stack of cards. App users can navigate back to the previous screen by pressing the back button or by calling closeScreen()
. You can think of this action as removing the top screen from the stack.
Closes the current screen.
closeScreen()
returns a promise that resolves when the screen closes.
function closeScreen(ClosedScreenData: ClosedScreenData): Promise<void>;
Data to send to the screen beneath this one in the stack. Learn more about stack navigation.
import wixNavigateMobile from "wix-navigate-mobile";
screenData = {
data: "This is my screen data.",
};
wixNavigateMobile.closeScreen(screenData).then(() => {
console.log("Screen closed.");
});
Get's the screen's data.
getScreenContext()
returns the screen's data. This includes any data context passed into the screen on which the widget is placed, such as data defined when the screen is opened using toScreen()
.
function getScreenContext(): Promise<ScreenContext>;
import wixNavigateMobile from "wix-navigate-mobile";
wixNavigateMobile
.getScreenContext()
.then((result) => {
console.log("Screen data from feedback screen:", result.data);
})
.catch((error) => {
console.error(error);
});
Directs the mobile app to open the specified URL in the device's browser.
The openURL()
function returns a Promise that resolves when the navigation is successful.
Supported URL formats:
http(s)://
.mailto:@?subject=
.function openURL(url: string): Promise<void>;
The URL to open.
import wixNavigateMobile from "wix-navigate-mobile";
/* Sample url value: 'https://wa.me/15551234567?text=I%27m%20interested%20in%20your%20car%20for%20sale'*/
wixNavigateMobile
.openURL(url)
.then(() => {
console.log("URL opened successfully!");
return;
})
.catch((error) => {
console.error(error);
// Handle the error
});
/* Promise resolves to void */