Skip to main content
Version: 7.2.0

Native Phone Call

You can make phone calls by using the native phone application. The following example shows how to launch the default phone application on the mobile device.

TypeScript
import PageSampleDesign from "generated/pages/pageSample";
import { Route, Router } from "@smartface/router";
import System from "@smartface/native/device/system";
import Button from "@smartface/native/ui/button";
import Application from "@smartface/native/application";


//You should create new Page from UI-Editor and extend with it.
export default class Sample extends PageSampleDesign {
btnCallPhone: Button;
constructor(private router?: Router, private route?: Route) {
super({});
}

// The page design has been made from the code for better
// showcase purposes. As a best practice, remove this and
// use WYSIWYG editor to style your pages.
centerizeTheChildrenLayout() {
this.dispatch({
type: "updateUserStyle",
userStyle: {
flexProps: {
flexDirection: 'COLUMN',
justifyContent: 'CENTER',
alignItems: 'CENTER'
}
}
})
}

onShow() {
super.onShow();
const { headerBar } = System.OS === System.OSType.ANDROID ? this : this.parentController;
Application.statusBar.visible = true;
headerBar.visible = true;
}

onLoad() {
super.onLoad();
this.centerizeTheChildrenLayout();

this.btnCallPhone = new Button({
text: "Call Smartface",
onPress: function () {
Application.call({
uriScheme: "tel:+1-650-617-3265",
});
},
});

this.addChild(this.btnCallPhone, "btnCallPhone", ".sf-button", {
height: 75,
width: 200,
margin: 10,
backgroundColor: "#0000FF",
textColor: "#FFFFFF",
flexProps: {
alignSelf: "CENTER",
},
});
}
}
Android Emulator

Some native features might require specific permissions and published app to work on Smartface due to Smartface Android Emulator itself not having necessary permissions.

List of permissions disabled by the emulator:

  • android.permission.WRITE_CALL_LOG

  • android.permission.READ_CALL_LOG

  • android.permission.PROCESS_OUTGOING_CALLS

You can add this permission to your AndroidManifest.xml file to enable the feature on your published app.