Phonegap email composer plugin for BlackBerry OS 7 - javascript

It might be repeating question but did not find any solution after search of whole day.
I'm developing phonegap application for blackberry os 7 but stuck into email(message) composer plugin. Is there any plugin of phonegap (cordova 2.7) for email composer that support blackberry os 7.
If you guys have any idea please share it. I have tried blackberry os message API and also tried mailto: of HTML5 but both are not working might be I'm doing in wrong way, if you guys have tried this and get success please share the process. Thanks

BlackBerry 7 provides html5 API blackberry.invoke.MessageArguments for email composer and it is easy to use instead of writing plugin for this.
Steps to implement blackberry.invoke.MessageArguments
Add these code to config.xml file
<feature id="blackberry.invoke" />
<feature id="blackberry.invoke.MessageArguments" />
<feature id="blackberry.message" />
Add this code into your js file and call the method.
function sendMail(){
var toRecipient = "user#gmail.com";
var subject = "Test Mail";
var body = "This is test mail, Please do not reply ...";
var args = new blackberry.invoke.MessageArguments(toRecipient, subject, body);
args.view = blackberry.invoke.MessageArguments.VIEW_NEW;
blackberry.invoke.invoke(blackberry.invoke.APP_MESSAGES, args);
}
Another way to use email composer in Blackberry 7 is use "mailto"
Sample code is:
var sMailTo = "mailto:";
sMailTo += escape(toRecipient) +"?subject=" +escape(subject) +"&body=" +escape(body) +"&cc=" +escape(ccRecipient);
window.open(sMailTo, '_self');

Related

crypto.subtle don't exist even with webcrypto-shim

I'm making a Cordova app with backbone and my goal was to achieve socket authentification with a JSON Web Token (JWT).
To sign my JWT, I used webcrypto-jwt and it worked well when using the app in the browser.
Then I tried the app on my mobile and BBAAMM...
webcrypto-jwt uses the browser's window.crypto.subtle module.
var cryptoSubtle = (window.crypto && crypto.subtle) ||
(window.crypto && crypto.webkitSubtle) ||
(window.msCrypto && window.msCrypto.Subtle);
But no subtle on android web view!
So I used webcrypto-shim to add the crypto.subtle. But it doesn't work.
That's a screenshot of my cordova's window object. It does have a crypto key but with no subtle in it!
So I can't sign my JWT.
https://github.com/PeculiarVentures/webcrypto-liner will provide you a working webcrypto on most platforms.
I have used it with https://github.com/square/js-jose just fine.
You can test your browsers support for WebCrypto with this - https://peculiarventures.github.io/pv-webcrypto-tests/
Ryan
WebCryptographyApi is not supported on Android WebView, and webcrypto-shim is not targeted to this component
The library is targeted to fix these browsers having prefixed and buggy webcrypto api implementations:
Internet Explorer 11, Mobile Internet Explorer 11,
Safari 8+, iOS Safari 8+.
So you are getting the expected behaviour. I think window.crypto that is showing Cordova is the old implementation.
If you need key storage I suggest use the Android native keystore (or iOS if you build for it). If you are looking for cryptographic function, include a pure javascript library
After more research and tests I have found a pure js library that works on cordova.
jsrsasign
I used it to authentificate my JWT. It doesn't use the the crypto.subtle module.
// Header
var oHeader = { alg: 'HS256', typ: 'JWT' };
// Payload
var oPayload = {};
var tNow = KJUR.jws.IntDate.get('now');
var tEnd = KJUR.jws.IntDate.get('now + 1day');
oPayload.iss = "http://foobar.com";
oPayload.sub = "mailto:someone#hello.com";
oPayload.iat = tNow;
oPayload.exp = tEnd;
oPayload.jti = "id123";
oPayload.aud = "http://someUrl";
oPayload.email = "userEmail";
oPayload.pwd = "userPassword";
oPayload.deviceId = "deviceId";
// Sign JWT.
var sHeader = JSON.stringify(oHeader);
var sPayload = JSON.stringify(oPayload);
//secret -> your secret that the server gave you.
var sJWT = KJUR.jws.JWS.sign("HS256", sHeader, sPayload, secret);
console.log(sJWT);
So that's it. It solved my problem.
I know that the undefined crypto.subtle error still exists. I did not find any solutions to that problem.
I supose that one day the developers in charge of cordova will make the effort to support the cryto module that we can find in all other browser but for now the only solution is to used third party libraries.

is it possible to save contacts on windows phone 8 emulator permanently in phonegap

Hi i'm unable to save the contacts in my windows phone 8 emulator permanently.contacts are saving just for a temporary period in people app.when i open that emulator and save contacts in it. They are getting saved but when i close that emulator and again reopened..no any contacts are showing in that people app .I want to import that contacts in my app for sending some info.but i cant proceed as its not showing any contacts in it.I gone through phonegap tutorial tried this code also.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var contact = navigator.contacts.create();
contact.displayName = "xyz";
var name = new ContactName();
name.givenName = "abc";
contact.name = name;
contact.save(onSaveSuccess,onSaveError);
function onSaveSuccess(contact) {
alert("Save Success");
}
function onSaveError(contactError) {
alert("Error = " + contactError.code);
}
AFAIK you can't do that because WP8 API doesn't allow that. You only have Read-only access to Contact API.
See the documentation.
EDIT: After reading a little more about your issues I found this one. So I think that your problem is with emulator only, that doesn't persist data after turned off.

How to display map on Blackberry by using Kony Studio?

I am new to Kony Studio. I have to display Google map on mobile by using kony Studio API.I tried and Its working fine on Android mobile.But On blackberry,It's not working on blackberry.Please give me some solution for this
Without some more information, hard to diagnose, but take a look at the Kony Map Widget documentation; there are some specific steps you need to follow to setup the map widget in Blackberry, and some Blackberry configurations that need to be set for the map to be able to test it in the emulator. Take a look here: Kony doc Map Reference
Following the above recommendation I found the below simple sample.
enter code here
function onPinClickCallBck(map)
{
alert("Some Message");
var mapBasicConf = {
id: "map1",
provider:constants.MAP_PROVIDER_GOOGLE,
mapKey:"0z5UtaSPUYj42f5qX0VAwmDGLX39Qxgbtcra0TA",
defaultPinImage: "kmpin.png",
isVisible:true, onPinClick:onPinClickCallBck
};
var mapLayoutConf = {
margin:[20,40,50,20],
containerWeight:100,
widgetAlignment:constants.WIDGET_ALIGN_BOTTOM_LEFT,padding: [10,10,10,10],
hExpand:false,
vExpand:false
};
var mapPSPConf = {
mode: constants.MAP_VIEW_MODE_HYBRID,
showCurrentLocation:constants.MAP_VIEW_SHOW_CURRENT_LOCATION_AS_PIN
};
var map = new kony.ui.Map(mapBasicConf,mapLayoutConf,mapPSPConf);
enter code here
I hope it is helpful.
Regards.
You need to subscribe BIS (Blackberry Internet Services) on the BB device to see map widget functioning properly.

Add arguments cc and bcc blackberry.invoke.MessageArguments in javascript

I am working a phonegap project for blackberry os 7 and I want to add cc and bcc arguments in email composed blackberry 7 API blackberry.invoke.MessageArguments ()
Actually this API accepting only three Arguments toRecipients, subject and email Body. Is there any solution add rest of two arguments cc and bcc. I have used following Code:
<script type="text/javascript">
var args = new blackberry.invoke.MessageArguments('foo#domain.com', 'hello', 'world');
args.view = blackberry.invoke.MessageArguments.VIEW_NEW; // New
blackberry.invoke.invoke(blackberry.invoke.APP_MESSAGES, args); // New Message
</script>
For more reference see on the following link.
Blackberry Invoke API for MessagesArguments
You can use "mailto:" and append the params you need to add accordingly.This should work.
If you are building phonegap application then you can use "mailto". I have tested on BlackBerry 7 device and it is woking fine for me.
Sample Code:
var sMailTo = "mailto:";
sMailTo += escape(toRecipient) +"?subject=" +escape(subject) +"&body=" +escape(body) +"&cc=" +escape(ccRecipient);
window.open(sMailTo, '_self');
Hope this will solve your problem.

How do I use PhoneGap with Worklight?

I wanted to know how Worklight uses PhoneGap as it's something I am required to do shortly. I hear that PhoneGap is 'build into' Worklight. If this is so, do I have to declare I'm using it, as in the below?:
<script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script>
And for that matter, if I do have to declare it, how do I know what version of PhoneGap it is utilising? If I don't have to declare it, will it just recognise my PhoneGap calls?
Any advice on this would be super as I just cannot find the answers on either the Worklight or PhoneGap websites.
Thanks!
Latest Worklight have a Cordova (formerly known as PhoneGap) 1.6.1
It's embedded automatically once you build your iOS/Android application, so you really do not need to add it's JS manually.
All of your Cordova calls will be recognized.
#creights there is not need to add Cordova.js internal into your Worklight application. By default Cordova plugin is included in your worklight app. You need to just use the functionality of plugin like camera,accelerator etc for an example i have a piece of code how to include camera in ur worklight application.
function takePicture() {
navigator.camera.getPicture(
function(data) {
var img = dom.byId('camera_image');
img.style.visibility = "visible";
img.style.display = "block";
//img.src = "data:image/jpeg;base64," + data;
img.src = data;
dom.byId('camera_status').innerHTML = "Success";
},
function(e) {
console.log("Error getting picture: " + e);
dom.byId('camera_status').innerHTML = e;
dom.byId('camera_image').style.display = "none";
},
{ quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, sourceType : navigator.camera.PictureSourceType.CAMERA});
};
Just copy the code into AppMain.js in ur js folder.
Just to update, The newest version on IBM Worklight is PhoneGap 2.2. It just happened this month (Dec 2012). When you write your code, it will auto fill (on default prefs).
For example
typing navigator.noti....will popup with the notification options for the alert and confirmation calls and its parameters (with some comments).

Categories