Add arguments cc and bcc blackberry.invoke.MessageArguments in javascript - 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.

Related

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.

Phonegap email composer plugin for BlackBerry OS 7

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');

equivalent of browserField.displayContent() in javascript

I tried to create my own app for BlackBerry using BlackBerry workflow SDK and phonegap.
I have a web service which sends html code and I need to use this code in a new window. I tried
window.document.write('test'); But when I use the back button on the phone, the application just quits.
Resolution without html code but url :
//Invoke blackberry browser
var args = new blackberry.invoke.BrowserArguments(url);
blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
BlackBerry WebWorks only has one window. You will need to work with that.
So, There are a couple ways you can do what I think you're looking to achieve.
1 - If you just need to show the new html and you dont care about the back button working you can just insert the html into the current page
document.querySelector("body").innerHTML = htmldata;
2 - If you need the back button to will need to save the htmlData to localStorage and change pages, then load the stored html.
localStorage.setItem("htmldata", htmlData);
window.location.href = "page2.html";
document.querySelector("body").innerHTML = localStorage.getItem("htmldata");;
EDIT
3 - Trap hardware key
blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, handleBack);
function handleBack() {
alert("handle back button");
}

Communication between browser tabs/windows using JavaScript [duplicate]

This question already has answers here:
Communication between tabs or windows
(9 answers)
Closed 6 years ago.
What's the most reliable way to have JavaScript communicate between tabs/windows of the same browser? For example, when Tab 2 starts audio playback, Tab 1 somehow knows about this and can pause its player.
I'm building a site with a music player... so at the moment if you open two tabs to the site, you could start music on both.
This is obviously bad, so I'm trying to find a solution.
For a more modern solution check out https://stackoverflow.com/a/12514384/270274
Quote:
I'm sticking to the shared local data solution mentioned in the question using localStorage. It seems to be the best solution in terms of reliability, performance, and browser compatibility.
localStorage is implemented in all modern browsers.
The storage event fires when other tabs makes changes to localStorage. This is quite handy for communication purposes.
Reference:
http://dev.w3.org/html5/webstorage/
http://dev.w3.org/html5/webstorage/#the-storage-event
Update to a modern solution, leaving the old one below for historical reasons.
You can use Broadcast Channel API to send and receive messages
https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API
// Connection to a broadcast channel
const bc = new BroadcastChannel('test_channel');
// Example of sending of a very simple message
// It doesn't have to be a string, it could be a JS object
bc.postMessage('This is a test message.');
To receive the message:
// A handler that only logs the event to the console:
bc.onmessage = function (ev) {
console.log(ev);
}
and to close the channel:
// Disconnect the channel
bc.close();
THIS IS HISTORICAL OLD WAY TO DO IT, USE THE METHOD ABOVE FOR MODERN BROWSERS!
You can communicate between browser windows (and tabs too) using cookies.
Here is an example of sender and receiver:
sender.html
<h1>Sender</h1>
<p>Type into the text box below and watch the text
appear automatically in the receiver.</p>
<form name="sender">
<input type="text" name="message" size="30" value="">
<input type="reset" value="Clean">
</form>
<script type="text/javascript"><!--
function setCookie(value) {
document.cookie = "cookie-msg-test=" + value + "; path=/";
return true;
}
function updateMessage() {
var t = document.forms['sender'].elements['message'];
setCookie(t.value);
setTimeout(updateMessage, 100);
}
updateMessage();
//--></script>
receiver.html:
<h1>Receiver</h1>
<p>Watch the text appear in the text box below as you type it in the sender.</p>
<form name="receiver">
<input type="text" name="message" size="30" value="" readonly disabled>
</form>
<script type="text/javascript"><!--
function getCookie() {
var cname = "cookie-msg-test=";
var ca = document.cookie.split(';');
for (var i=0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(cname) == 0) {
return c.substring(cname.length, c.length);
}
}
return null;
}
function updateMessage() {
var text = getCookie();
document.forms['receiver'].elements['message'].value = text;
setTimeout(updateMessage, 100);
}
updateMessage();
//--></script>
I don't think you need cookies. Each document's JavaScript code can access the other document elements. So you can use them directly to share data.
Your first window w1 opens w2 and save the reference
var w2 = window.open(...)
In w2 you can access w1 using the opener property of window.
There is also an experimental technology called Broadcast Channel API that is designed specifically for communication between different browser contexts with same origin. You can post messages to and recieve messages from another browser context without having a reference to it:
var channel = new BroadcastChannel("foo");
channel.onmessage = function( e ) {
// Process messages from other contexts.
};
// Send message to other listening contexts.
channel.postMessage({ value: 42, type: "bar"});
Obviously this is experiental technology and is not supported accross all browsers yet.
You can do this via the local storage API. Note that this works only between two tabs. You can't put both sender and receiver on the same page:
On the sender page:
localStorage.setItem("someKey", "someValue");
On the receiver page:
$(document).ready(function () {
window.addEventListener('storage', storageEventHandler, false);
function storageEventHandler(evt) {
alert("storage event called key: " + evt.key);
}
});
Below window(w1) opens another window(w2). Any window can send/receive message to/from another window. So we should ideally verify that the message originated from the window(w2) we opened.
In w1
var w2 = window.open("abc.do");
window.addEventListener("message", function(event){
console.log(event.data);
});
In w2(abc.do)
window.opener.postMessage("Hi! I'm w2", "*");
Communicating between different JavaScript execution context was supported even before HTML5 if the documents was of the same origin.
If not or you have no reference to the other Window object, then you could use the new postMessage API introduced with HTML5. I elaborated a bit on both approaches in this Stack Overflow answer.
You can communicate between windows (tabbed or not) if they have a child-parent relationship.
Create and update a child window:
<html>
<head>
<title>Cross window test script</title>
<script>
var i = 0;
function open_and_run() {
var w2 = window.open("", "winCounter");
var myVar=setInterval(function(){myTimer(w2)},1000);
}
function myTimer(w2) {
i++;
w2.document.body.innerHTML="<center><h1>" + i + "</h1><p></center>";
}
</script>
</head>
<body>
Click to open a new window
<button onclick="open_and_run();">Test This!</button>
</body>
</html>
Child windows can use the parent object to communicate with the parent that spawned it, so you could control the music player from either window.
See it in action here: https://jsbin.com/cokipotajo/edit?html,js,output
I found a different way using HTML5 localstorage. I've created a library with events like API:
sysend.on('foo', function(message) {
console.log(message);
});
var input = document.getElementsByTagName('input')[0];
document.getElementsByTagName('button')[0].onclick = function() {
sysend.broadcast('foo', {message: input.value});
};
https://github.com/jcubic/sysend.js
It will send messages to all other pages, but not to the current one.
EDIT:
The library in the newest version also supports broadcast channel communication, but still, it works in IE11 that only supports local Storage. It also supports cross-origin communication (different domains) but a little bit of code.
The latest API also supports the emit function that executes events also on the same page.
Even latest version, also suport managing the windows, send message to particular window or get list of widows/tabs.
With Flash you can communicate between any window, any browser (yes, from Firefox to Internet Explorer at runtime) ...any form of instance of Flash (Shockwave or ActiveX).

Categories