SMS and phone calls for ionic projects

Source: Internet
Author: User

Original address: http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/ionic-sms-and-call/

A recent ionic project needs to implement texting and calling, summarizing the problems encountered and how to implement them.

1. About the phone

In HTML, it is convenient to make a call to add in config:

<access origin= "tel:*" launch-external= "yes"/>

Then write this in HTML:

<a href= "tel:10086" > Call 10086</a>

But I wanted to get a click on the phone, so I made a change:

In HTML:

<button ng-click= "Callfriend ($event, friend)" ></button>

JS in:

$scope. callfriend = function ($event, friend) {window.open (' Tel: ' + friend.   PhoneNumber); Get the call time var time=new date ();}

Sometimes do not want to automatically identify the phone, in order to prevent phone recognition, you can add this sentence in the header file:

<meta name= "format-detection" content= "Telephone=no" >

2. About texting, is the plugin used by Ng-cordova $cordovasms:

Add the plugin First:

Cordova Plugin Add Https://github.com/cordova-sms/cordova-sms-plugin.git

Remember to rely on the Ng-cordova in the app. js to rely on $cordovaSms in the controller that sends the SMS .

I realized that clicking the text button will pop up a popup:

To add a click event to the HTML:

<button ng-click= "Opensendmessage (phonenumber)" ></button>

Write the function that sends the SMS in the controller:

Open the Popup$scope.opensendmessage = function (PhoneNumber) {$rootScope. Sendmessagepopup.show (PhoneNumber) of the sending SMS. Then (    function (Result) {return result; });}; $scope. SMS = {number: ' 10086 ', message: ' Happy birthday '};var options = {replacelinebreaks:false,//true to replace \ n by a n EW line, False by default Android: {intent: "//Send SMS with the native Android SMS Messaging//intent: '//S End SMS without open any other app//intent: ' Intent '//Send SMS inside a default SMS app}}; $scope. sendsms = Functio    N () {$cordovaSms. Send (' 10086 ', ' Happy Birthday ', options). Then (function () {alert (' Send SMS successfully ');    }, function (Error) {alert (' Send SMS failed '); });};

SMS and phone calls for ionic projects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.