I would like to implement a App in Phonegap with the Adobe Phonegap Builder under http://build.phonegap.com. And I would like to use the Plugin https://build.phonegap.com/plugins/2420 to send SMS.
In my config.xml stay:
<gap:plugin name="com.cordova.plugins.sms" version="0.1.2" />
The Adobe PhoneGap Builder shows this plugin as integrate plugin.
My next action was to download and add the /www/sms.js from https://github.com/cordova-sms/cordova-sms-plugin/tree/48d9630 and include this in the index.html
Then I add to a JavaScript function like the example on Git:
var message = "Testing SMS by sending it to ";
var options = {
replaceLineBreaks: false, // true to replace \n by a new line, false by default
android: {
intent: 'INTENT' // send SMS with the native android SMS messaging
//intent: '' // send SMS without open any other app
}
};
var success = function () {
alert('Message sent successfully');
};
var error = function (e) {
alert('Message Failed:' + e);
};
sms.send("MY Handy number", "sms", options, success, error);
In a other Post I found that replace
var exec = require('cordova/exec');
with
var exec = cordova.exec
can help, but it do not work.
Ok .
i have "fix" it.
there must the first include js, in this order.
Also its important that the file sms.js is not exists.
In the config.xml
you must put in:
an that is it. :)
Related
I am a .NET developer and new to electron and node.js.
From my electron application, I need to call one function inside a .NET class library DLL which will generate some document and will send to print.
I need to use this electron application only on the windows machine. I see plugin Edge.js, but am not sure this will work for me and also don't know how to include in my project.
Edge.js will do the trick.
See the following snippet:
var edge = remote.require('electron-edge');
var toErMahGerd = edge.func({
assemblyFile: 'ERMAHGERD.dll',
typeName: 'ERMAHGERD.Translate',
methodName: "ToErMahGerd"
});
document.getElementById("translate-btn").addEventListener("click", function (e) {
var inputText = document.getElementById("input-text").value;
toErMahGerd(inputText, function (error, result) {
document.getElementById("output-text").innerHTML = result;
});
});
And here is the GitHub-repo with not only good docs to dive in but a simple getting started.
I have a cordova app that I want to run on desktops using Node Webkit.
I need to replace cordova.plugins.email() function with a Node Webkit equivelant but am struggling to find the info I need.
Can anyone help?
//email composer
$('#stage').on('click', '#email', function(event){
var pdfatt = (this.getAttribute('data-pdfemail'));
var profforename = window.localStorage.getItem('profForename');
var profsurname = window.localStorage.getItem('profSurname');
var profemail = window.localStorage.getItem('profEmail');
cordova.plugins.email.isAvailable(
function (isAvailable) {
cordova.plugins.email.open({
body:'<p><img src="wp-content/uploads/2016/06/Email_Header.jpg"/></p><br><br>From:<p>'+profforename+' '+profsurname+'</p><p>Tel:'+proftel+'</p><p>Mob: '+profmob+'</p><p>Email: '+profemail+'</p><br><br><img height="30px" src='+baseurl+'"/wp-content/uploads/2016/06/download-pdf.jpg"/><br>Click To Download the PDF<br><br><br><p><img src="/wp-content/uploads/2016/06/Email_Footer.jpg"/></p>',
subject: 'subject',
isHtml: true
});
//alert('Service is not available') unless isAvailable;
}
);
});
The above code basically opens up a new email and pre-populates the email. I cannot find much information out there on how to do this. I have come across nodemailer but I don't think this is what I need as I would want to open up and email in Outlook and prepopulate, leaving the user to add the email address.
Many thanks
oh this is so simple, not sure why I tried to overcomplicate it! Turned out I sneeded to use the Nodewebkit GUI Library.
// Load native Nodewebkit UI library.
var gui = require('nw.gui');
gui.Shell.openExternal('mailto:test#example.com?subject=test&body=hello');
I'm new to Cordova, any help would be appreciated.
I created a new Cordova Project in VS2015 and added the Cordova SMS plugin to my project (https://www.npmjs.com/package/cordova-sms-plugin).
I added this code to /www/scripts/index.js function onDeviceReady (as per documentiation for plugin):
function onDeviceReady() {
// Handle the Cordova pause and resume events
document.addEventListener( 'pause', onPause.bind( this ), false );
document.addEventListener( 'resume', onResume.bind( this ), false );
var numberString = "aoeuaeu";
var bypassAppChooser = true;
//CONFIGURATION
var options = {
replaceLineBreaks: false,
android: {
intent: 'INTENT' // send SMS with the native android SMS messaging
}
};
var successSMS = function () { alert('Message sent successfully'); };
var errorSMS = function (e) { alert('Message Failed:' + e); };
sms.send("0811231234", "Testing123", options, successSMS, errorSMS);
I debug the project using Debug, Android, Ripple - Nexus (Galaxy) selected options. When I place a breakpoint on the sms.send line of code and I add a watch for 'sms.send', I can see the object exists.
When I single step, this line in sms.js seems to be the last line that executes:
// fire
exec(
success,
failure,
'Sms',
'send', [phone, message, androidIntent, replaceLineBreaks]
);
I then get the following error message in Ripple:
'Sms.send We seem to be missing some stuff :( What is kinda cool though you can fill in the textarea to pass a json object to the callback you want to execute).'
I can see that all of the objects in that line is defined (success, failure, phone, message, androidIntent, replaceLineBreaks). When I 'step into' this line, it continues to execute code in ripple.js, but it becomes hard to follow for a person, since there are no line breaks in this file.
What am I doing wrong? I've read through all the documentation I can find & searched stackoverflow questions and can't seem to find any solutions to the problem.
I've uploaded this entire project (zipped), which can be downloaded at:
https://drive.google.com/file/d/0BwWgTMh-JLbfNHV0MlE5Yk5IZ3M/view?usp=sharing
Thanks in advance
Thank you Cordova team at Microsoft for helping me with an answer:
"Ripple has the ability to emulate some but not all plugins. SMS is not one of the plugins that it can fully emulate. However, in the message that pops up, you do have the ability to hit the Success or Fail buttons which will report back to the app that it was successful or not in sending the SMS. While that doesn’t actually send a message, it does let you test your app to see how it behaves for different results.
I tried the bit of sample code you included in the first email. In Ripple, I was able to change the alert by hitting the different buttons.
Trying other deployment methods, in both the VS Android Emulator and the Google Emulator they showed failure alert messages that they don’t support SMS messages. I then launched it on an Android phone device and it said it was successful.
So I believe your options are mainly using Ripple to fake sending of messages or using a device for testing."
Please tell me the way to implement in-app-purchase using Cordova plugin.
I'm developing Android application using Cordova.
There are some in-app-purchase plugins but I decide to use Cordova Purchase Plugin.
I did some setups along README.md of In-App Purchase for PhoneGap / Cordova iOS and Android.
As a result, I could call the Plugin using Demo of the Purchase Plugin for Cordova with my little modification. (See the following, it is a portion of code.)
app.initStore = function() {
if (!window.store) {
log('Store not available');
return;
}
// Enable maximum logging level
store.verbosity = store.DEBUG;
// Enable remote receipt validation
// store.validator = "https://api.fovea.cc:1982/check-purchase";
// Inform the store of your products
log('registerProducts');
store.register({
id: 'myProductA',
alias: 'myProductA',
type: store.CONSUMABLE
});
// When any product gets updated, refresh the HTML.
store.when("product").updated(function (p) {
console.info("app.renderIAP is called");
app.renderIAP(p);
});
// Log all errors
store.error(function(error) {
log('ERROR ' + error.code + ': ' + error.message);
});
// When purchase of an extra life is approved,
// deliver it... by displaying logs in the console.
store.when("myProductA").approved(function (order) {
log("You got a ProductA");
order.finish();
});
// When the store is ready (i.e. all products are loaded and in their "final"
// state), we hide the "loading" indicator.
//
// Note that the "ready" function will be called immediately if the store
// is already ready.
store.ready(function() {
var el = document.getElementById("loading-indicator");
console.info(el + "ready is called")
if (el)
el.style.display = 'none';
});
// When store is ready, activate the "refresh" button;
store.ready(function() {
var el = document.getElementById('refresh-button');
console.info(el + "ready is called and refresh-button show?");
if (el) {
el.style.display = 'block';
el.onclick = function(ev) {
store.refresh();
};
}
});
// Refresh the store.
//
// This will contact the server to check all registered products
// validity and ownership status.
//
// It's fine to do this only at application startup, as it could be
// pretty expensive.
log('refresh');
store.refresh();
};
It did not show 'Store not available' that is shown when plugin is not available, show 'registerProducts', and 'refresh.'
(*Of course I added 'myProductA' to in-app Products on Google Play Developer Console.)
But I noticed that the below function is not called.
store.when("product").updated(function (p)
And also I couldn't understand what the parameter should fill in it, so I commented out the below.
(*I did remove the comment out, but it still not working.)
store.validator = "https://api.fovea.cc:1982/check-purchase";
I guess those things make something wrong.
I'm not sure what is stack on me, so my question is not clearly.
I want some clues to solve it... or I shouldn't implement in-app-purchase using Cordova plugin?
Please give me your hand.
(I'm not fluent in English, so I'm sorry for any confusion.)
You can try this plugin as an alternative: https://github.com/AlexDisler/cordova-plugin-inapppurchase
Here's an example of loading products and making a purchase:
inAppPurchase
.buy('com.yourapp.consumable_prod1')
.then(function (data) {
// ...then mark it as consumed:
return inAppPurchase.consume(data.productType, data.receipt, data.signature);
})
.then(function () {
console.log('product was successfully consumed!');
})
.catch(function (err) {
console.log(err);
});
It supports both Android and iOS.
Step for Integrate In-App billing in Phone-gap app.
1>> clone this project in your pc from this link In-App billing Library
2>> using CMD go to your root directory of your phonegap application
3>> then run this command cordova plugin add /path/to/your/cloned project --variable BILLING_KEY="QWINMERR..........RIGR"
Notes : for BILLING_KEY go to Developer console then open your application and go to Service& APIs for more info Please refer attached screenshots
I am using this plugin and trying to trigger local notification for my Cordova iOS app with Local notifications plugin.
I dd following steps:
Installed plugin: cordova plugin add de.appplant.cordova.plugin.local-notification#0.7.7
Updated config.xml: gap:plugin name="de.appplant.cordova.plugin.local-notification"
Added the following JavaScript in head tag for
index.html
plugin.notification.local.promptForPermission(function (granted) {
alert("promptForPermission: "+granted);
});
plugin.notification.local.hasPermission(function (granted) {
alert("hasPermission: "+granted);
});
Have a button in index.html to create a local notification after 5 secs.
Code for that looks like this:
function setLocalNotification()
{
alert("from setLocalNotification");
var t = new Date();
t.setSeconds(t.getSeconds() + 3);
window.plugin.notification.local.add({
title: 'Scheduled with delay',
message: 'Test Message ',
date: t
});
alert("alert set");
};
I do see a prompt for user's permission and the alert from hasPermission method shows the value as true. But I am still not able to get the actual local notification I am trying to set by clicking a button. I have already updated the APPLocalNotification.m file for the this issue by copying this fix.
I don't see any more errors in the console log but I am still not able to trigger a local notification.
You should check if the device is ready ( document.addEventListener('deviceready', function () {
) and also check if the plugin is correctly added $ cordova plugin ls.
Make sure you have "< script type="text/javascript" src="cordova.js">
" in your html .
Good luck!