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 code blocks includes example of how to implement, override & add components with theme. Create page with UI-Editor to make your page themeable and then able to implement themeable components programmatically. Once page created with UI-Editor, it generates class under scripts/generated/pages. Extend that class with below typescript classes.

TypeScript
JavaScript
TypeScript
import PageSampleDesign from 'generated/pages/pageSample';
import FlexLayout = require('sf-core/ui/flexlayout');
import Application = require('sf-core/application');
import System = require('sf-core/device/system');
import Button = require('sf-core/ui/button');
//You should create new Page from UI-Editor and extend with it.
export default class Sample extends PageSampleDesign {
btnCallPhone: Button;
constructor() {
super();
// Overrides super.onShow method
this.onShow = onShow.bind(this, this.onShow.bind(this));
// Overrides super.onLoad method
this.onLoad = onLoad.bind(this, this.onLoad.bind(this));
this.layout.flexDirection = FlexLayout.FlexDirection.ROW;
this.layout.justifyContent = FlexLayout.JustifyContent.CENTER;
this.layout.alignItems = FlexLayout.AlignItems.CENTER;
this.layout.flexWrap = FlexLayout.FlexWrap.WRAP;
}
}
/**
* @event onShow
* This event is called when a page appears on the screen (everytime).
* @param {function} superOnShow super onShow function
* @param {Object} parameters passed from Router.go function
*/
function onShow(superOnShow: () => void) {
const { headerBar } = System.OS === "Android" ? this : this.parentController;
superOnShow();
Application.statusBar.visible = true;
headerBar.visible = true;
}
/**
* @event onLoad
* This event is called once when page is created.
* @param {function} superOnLoad super onLoad function
*/
function onLoad(superOnLoad: () => void) {
superOnLoad();
this.btnCallPhone = new Button({
text: "Call Smartface",
onPress: function () {
Application.call({
uriScheme: "tel:+1-650-617-3265"
});
}
});
this.layout.addChild(this.btnCallPhone, "btnCallPhone", ".sf-button", {
height: 75,
width: 200,
margin: 10,
backgroundColor: "#0000FF",
textColor: "#FFFFFF",
flexProps: {
alignSelf: "CENTER"
}
});
}
JavaScript
const Page = require('sf-core/ui/page');
const extend = require("js-base/core/extend");
const Color = require('sf-core/ui/color');
const Button = require('sf-core/ui/button');
const FlexLayout = require("sf-core/ui/flexlayout");
const Application = require("sf-core/application");
var page1 = extend(Page)(
function(_super) {
_super(this);
var btnCallPhone = new Button({
height: 75,
width: 200,
margin: 10,
text: "Call Smartface",
backgroundColor: Color.BLUE,
textColor: Color.WHITE,
alignSelf: FlexLayout.AlignSelf.CENTER,
onPress: function(){
Application.call("tel:+1-650-617-3265");
}
});
this.layout.flexWrap = FlexLayout.FlexWrap.WRAP;
this.layout.flexDirection = FlexLayout.FlexDirection.ROW;
this.layout.justifyContent = FlexLayout.JustifyContent.CENTER;
this.layout.addChild(btnCallPhone);
}
);
module.exports = page1;