- Notifications
You must be signed in to change notification settings - Fork4
[unmaintained] This module allows your app to register listeners to the device phone. With this listeners you'll be able to know when the phone is receiving a call, making a call, etc.
License
ulizama/phonelistener
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This module allows your app to register listeners to the device phone. With this listeners you'll be able to know when the phone is receiving a call, making a call, etc.
Require the module on your tiapp.xml:
<modules> <moduleplatform="android">com.baboonmedia.phonelistener</module> </modules>
You will also need to request some permissions to be able to listen to phone changes:
<manifest> <uses-permissionandroid:name="android.permission.PROCESS_OUTGOING_CALLS"/> <uses-permissionandroid:name="android.permission.READ_PHONE_STATE"/> </manifest>
Then on your app, you'll need to require the module, set the listener and initialize the module:
varPhoneManager=require('com.baboonmedia.phonelistener');PhoneManager.addEventListener('phoneChange',function(e){if(e.status=='incoming'){Ti.API.info('Ringing Icnoming from '+e.phone);}elseif(e.status=='outgoing'){Ti.API.info('Outgoing ringing to '+e.phone);}elseif(e.status=='offhook'){Ti.API.info('Call answered');}elseif(e.status=='hanged'){Ti.API.info('Call hanged up');}});PhoneManager.init();
You listen to thephoneChangeevent which will return an event with two properties:statuswhich is the current status of the phone, andphone which is the phone number used.
** NOTE: Only the incoming and outgoing events return the 'phone' number so you need to make sure to save it on those events. **
| Status | Description | Phone |
|---|---|---|
| incoming | The phone is ringing with an incoming call. | Yes, with the number that is calling. |
| outgoing | A number has been dialed and the phone is waiting for recipient to pickup. | Yes, with the dialled number. |
| offhook | Phone is off the hook. A call is in place. | No |
| hanged | The phone has been hanged. | No |
Usually the order of an actual call will be:
(incoming|outgoing) -> offhook -> hanged
And the order of a call with no answer will be:
(incoming|outgoing) -> hanged
Uriel Lizamauriel@baboonmedia.com
This work is released under the MIT license.
Appcelerator, Appcelerator Titanium and associated marks and logos are trademarks of Appcelerator, Inc.
Titanium is Copyright (c) 2008-2012 by Appcelerator, Inc. All Rights Reserved.
About
[unmaintained] This module allows your app to register listeners to the device phone. With this listeners you'll be able to know when the phone is receiving a call, making a call, etc.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
