A Fuse Powered Company

Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How can I tell if a device can run system.openURL("tel:")
Started by ksan Jun 12 2014 08:39 PM

- - - - -
7 replies to this topic

Best Answer jonjonsson , 12 June 2014 - 08:52 PM

Better option could be native.canShowPopup("sms")

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

Is there any way to check a system parameter to see if the device my app is running on is capable of making phone calls? The API page for system.openURL("tel:") does not mention any such option but I think it would make sense to check first before attempting the call. Any insights? 

 

Thanks much for your help. Regards,

Kerem



[TOPIC: post.html]
#2

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,048 posts
  • Enterprise

Maybe there is a better way, but for Android  'deviceID' has some hints: http://docs.coronalabs.com/api/library/system/getInfo.html#deviceid

 

Then maybe for iOS check if 'model' returns 'iphone'?



[TOPIC: post.html]
#3

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,048 posts
  • Enterprise

  Best Answer

Better option could be native.canShowPopup("sms")



[TOPIC: post.html]
#4

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

Better option could be native.canShowPopup("sms")

 

Great idea! Thanks much. This is much better than checking names since there will always be names you miss in the 5000+ devices on Android camp and then there is the issue of new devices getting released. Will try and let you know but see no reason it shouldn't work.

 

Edit - Seems to work well. Thanks once again.



[TOPIC: post.html]
#5

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

Hmm, I guess I jumped too soon. Seems like native.canShowPopup("sms") returns true on iPad since iPad can run Messages app and send iMessages which probably trick the API. Not sure if any Android tablets will fall this way. More checking needed. 

 

In the meanwhile, if anyone knows of an easier way to tell if a device can make phone calls or not I would really appreciate to find out about it. Thank you so much!!!



[TOPIC: post.html]
#6

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

Ok. On Android it seems like the native.canShowPopup("sms") call on an Android tablet returns false so we're probably good there. I used the system.getInfo("model") to weed out the iPads so now I seem to be able to detect iPhones and Android Phones pretty accurately. All good for now. 



[TOPIC: post.html]
#7

lano78

[GLOBAL: userInfoPane.html]
lano78
  • Contributor

  • 370 posts
  • Corona SDK

local isPhone = ( ( string.sub( system.getInfo("architectureInfo"), 1, 6 ) == "iPhone" ) and (system.getInfo("platformName") == "iPhone OS") ) or ( (system.getInfo("platformName") == "Android") and (native.canShowPopup("sms") == true) )

Edited by lano78, 23 June 2014 - 03:33 AM.


[TOPIC: post.html]
#8

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

local isPhone = ( ( string.sub( system.getInfo("architectureInfo"), 1, 6 ) == "iPhone" ) and (system.getInfo("platformName") == "iPhone OS") ) or ( (system.getInfo("platformName") == "Android") and (native.canShowPopup("sms") == true) )

 

Yup. Thats exactly the way to go. Thanks much for sharing.




[topic_controls]
[/topic_controls]