Phonegap Phone Number to Dialer/SMS

  • 2
  • Question
  • Updated 4 years ago
We are having issues getting Phonegap to bring up the dialer, SMS, and email capabilities. We have tried countless plugins and have poured through many a forum. We are currently 0/20. Can anyone help us with a walkthrough to make sure we aren't forgetting some important piece to this puzzle?
Photo of Derek Hobbs

Derek Hobbs

  • 7 Posts
  • 0 Reply Likes
  • anxious and frustrated

Posted 4 years ago

  • 2
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
If you use
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>

with the whitelist plugin and such links in your html, things work just fine.
Photo of Derek Hobbs

Derek Hobbs

  • 7 Posts
  • 0 Reply Likes
Thank you very much kind sir. I will get back to you after i have tried it out!
Photo of Derek Hobbs

Derek Hobbs

  • 7 Posts
  • 0 Reply Likes
Photo of Derek Hobbs

Derek Hobbs

  • 7 Posts
  • 0 Reply Likes
didnt use the correct code insertion syntax on this post. mb
Photo of Derek Hobbs

Derek Hobbs

  • 7 Posts
  • 0 Reply Likes
This is what we have right now
Photo of Derek Hobbs

Derek Hobbs

  • 7 Posts
  • 0 Reply Likes
CSP Meta -


<meta http-equiv="Content-Security-Policy"
content="default-src *;
style-src 'self' 'unsafe-inline' 'unsafe-eval';
script-src 'self' 'unsafe-inline' 'unsafe-eval';">


js code -


document.location.href = 'tel:1-913-484-9948';
window.plugins.CallNumber.callNumber(onSuccess, onError, number, 1);


config.xml

<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="tel:*" launch-external="yes"/>
<access origin="sms:*" launch-external="yes"/>
<access origin="mailto:*" launch-external="yes"/>
<access origin="geo:*" launch-external="yes" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />

<platform name="android">
<allow-intent href="market:*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<preference name="Orientation" value="portrait" />
<engine name="android" spec="~4.1.1" />
<preference name="android-minSdkVersion" value="14" />
<engine name="ios" spec="~3.9.2" />
</widget>

Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
If you have ANY javascript in your index.html, move that javascript to a separate file. That should your issue.

Jesse
Photo of Jake Wilson

Jake Wilson

  • 6 Posts
  • 1 Reply Like
It's in a seperate file atm, in the js folder, not in root, if that matters?
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
Hmm....
Since this is your first post, please answer the following question.
- Is this your first hybrid App?
- Are you using the Phonegap Desktop App?
- Are you using CLI, SDK or Build? Please do not assume the answer, please read the link.

I'll be up for a few hours.

Jesse
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Jake,
I just noticed this thread was started by "Derek". Are you working with "Derek"? or are you trying to hijack this thread?

Jesse
Photo of Jake Wilson

Jake Wilson

  • 6 Posts
  • 1 Reply Like
I am working with Derek. This is my first hybrid app, I am not using the desktop app. I am using the CLI, not build or SDK.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
This has struck me:

document.location.href = 'tel:1-913-484-9948';
window.plugins.CallNumber.callNumber(onSuccess, onError, number, 1);


Some questions:

1. a. Is the first line executed without any condition and not upon an event? If so, what is the purpose of your app....just always call that one phone number?
1. b. Are you aware that Apple broke the document.location object when introducing iOS9?

2. a. Why do you still use the CallNumber plugin? Don't you trust the first line of code?
2. b. How are the callback functions defined? And where is the variable 'number' set to a specific value? Is the latter done based upon conditions or events?
Photo of Jake Wilson

Jake Wilson

  • 6 Posts
  • 1 Reply Like
1a: it is inside a function that is called onclick
1b: I was not

2a: the first line of code isn't working and I've been throwing everything i can find at it.
2b: my callbacks are copy and pasted from the documentation atm, and number is set to a phone number earlier in the function based on conditions passed to the function.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
a. I would suggest you use a hyperlink around whatever is clicked, as in
<a id="myButtonLink" href="tel:1234567">Button</a>
If you can't use a hyperlink around your click object, hide such hyperlink elsewhere, invisibly, and upon the click event you have now, call
document.getElementById('myButtonLink').click();

b. Since you are building with CLI, you might be lost a bit. This is the Phonegap Build community, the place for developers who don't install and maintain node, Java, Phonegap, SDK's, plugins and whatnot.
Your question may be better asked and answered in the Phonegap Google Group or at Stackoverflow.
Photo of Jake Wilson

Jake Wilson

  • 6 Posts
  • 1 Reply Like
B: I will pack it along then, thanks for the help!
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Jake and @Derek,
This forum is not for CLI. This forum is Phonegap Build, a cloud-based build system by Adobe/Phonegap. I'm surprised Petra did not catch this. As such, the answer *May Be* slanted toward Build.

The following forums are more helpful for CLI:

- Google Group for Cordova/Phonegap
- Adobe Communities for Phonegap CLI

Best of Luck
Jesse
Photo of Jake Wilson

Jake Wilson

  • 6 Posts
  • 1 Reply Like
Thank you Jesse!
Photo of Derek Hobbs

Derek Hobbs

  • 7 Posts
  • 0 Reply Likes
We are rebuilding it as a PhoneGap Build project so that we can get some assistance. The repo is getting fetched now. I would really really appreciate your guys input considering this is our first hybrid app. You guys are champs, so I am excited to learn some new stuff!

Thanks again.
Photo of Jake Wilson

Jake Wilson

  • 6 Posts
  • 1 Reply Like
Yeah, so I rebuilt it with Build. It works now.
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Derek,
you are welcome to continue on this forum. However, the use of CLi is going to complicate an Thread. You'll need to be clear that you are using CLI.

FWIW: There are no significant reasons to use CLI to build an app on Phonegap Build. If you are using CLI to start the app, you are better off creating your own starter template.

Best of Luck
Jesse