12-10-2012 11:26 AM - edited 12-10-2012 11:28 AM
I have a webworks app and I would like to receive push notifications from urbanairship as I do for android and iphone.
But I don´t know how to do it since there are not any documentation. I hope you could help.
I don't know if in server URL I should put: "https:go.urbanairship.com/api/push" or the push api of bb
I have the <feature id="blackberry.push" /> in config.xml
And I have this JavaScript code:
Do I need anything else?
function openBISPushListener(){
var port = 31892; //the port that blackberry gave me
var serverUrl = "http://pushapi.eval.blackberry.com";
var appId = "xxxx"; //the apid that blackberry gave me.
var max = 100;
var wakeUpPage = "index.html";
try {
var ops = {port : port, appId : appId, serverUrl : serverUrl, wakeUpPage : wakeUpPage, maxQueueCap : max};
blackberry.push.openBISPushListener(ops, onData, onRegister, onSimChange);
}
catch (err) {
alert(err);
}
}
function onRegister(status) {
if (status == 0) {
alert("success");
}
else if (status == 1) {
alert("network error");
}
else if (status == 2) {
alert("rejected by server");
}
else if (status == 3) {
alert("invalid parameters");
}
else if (status == -1) {
alert("general error");
}
else {
alert("unknown status");
}
}
function onData(data) {
var resultDiv = document.getElementById("resultDiv");
try {
resultDiv.innerHTML += "Resultado";
resultDiv.innerHTML += "<br>" + blackberry.utils.blobToString(data.payload);
return 0; //indicate acceptance of payload for reliable push
}
catch (err) {
alert(err);
}
}
function onSimChange() {
var resultDiv = document.getElementById("resultDiv");
resultDiv.innerHTML += "<br>" + "SIM card is changed!";
}
Thank you in advance!
12-10-2012 11:47 AM
Hi,
There is documentation available, but before I can point you in the right direction, are you developing for BlackBerry 10 or an older version of the OS?
Thanks,
Matt
12-10-2012 01:48 PM
Old version
12-10-2012 02:05 PM
Have you looked at the descriptions of the arguments and callbacks needed from the API reference for push?
(** these are different from the BlackBerry 10 push APIs **)
https://developer.blackberry.com/html5/apis/blackb
The server URL is the URL that you were sent when you registered to use push.
It should be of the form:
http://cp{cpid}.pushapi.eval.blackberry.com
Replace {cpid} with your content provider ID.
12-10-2012 02:07 PM
Your sample code looks like it should work to me. Give it a try and see what happens. Have you written a Push Initiator? (an application to send out pushes with)
12-11-2012 05:41 AM
But I´m interested in use urban airship as the push initiator as I do for Android and IOS.
UA with the ID sends push to the app. But I think I have to register in some way. There is documentation for bb native app but not for webworks.
12-11-2012 08:19 AM
The API reference I linked to is pretty good at describing what functions need to be called. Is there anything specific about the blackberry.push.openBISPushListener function that you're unclear about?
To be able to send pushes to a BlackBerry, you need to implement a Push Initiator that sends messages using PAP XML. We have a Push Service SDK you can use to help with this:
https://developer.blackberry.com/devzone/develop/p
Let me know if you have any questions.
Thanks,
Matt