WebWorks Push Client

Hello

I'm sort of stuck in the logical process to receive a push message in an application webworks. The sample application works fine and I can receive messages with him. I guess I understand something wrong.

What I understand so far is:

1. create pushservice

2. create the event listener

3 activate the application to launch on push

4 create the channel

and everything should be good... or not? Lets talk about code:

config. XML (part)


    post_notification
    _sys_use_consumer_push
    read_device_identifying_information


    APPLICATION
    
        bb.action.PUSH
        application/vnd.push
    

JavaScript :

function createPushService() {
  try {

        ops = { invokeTargetId : 'bert.pushcapture.invoke.push',
                appId : 'XXX-XXXX...',
                ppgUrl : 'http://cpXXX.pushapi.na.blackberry.com'
        };

        blackberry.push.PushService.create(ops, successCreatePushService, failCreatePushService, onSimChange, onPushTransportReady);  

  }
  catch (err) {
    alert(err);
  }
} 

function successCreatePushService(service) {
    //alert("Created Push service");
    // check this **bleep**
    pushService = service;
    blackberry.event.addEventListener("invoked", onInvoke);
    launchApplicationOnPush(true, launchApplicationCallback);
}

function failCreatePushService(result) {
    alert("Error: Received error code (" + result + ") after " + "calling blackberry.push.PushService.create.");
}

function onPushTransportReady(result) {
    if (result == blackberry.push.PushService.SUCCESS) {
                alert("successful Configuration");
        } else {            

            if (result == blackberry.push.PushService.INTERNAL_ERROR) {
                alert("Error: An internal error occurred while calling launchApplicationOnPush. " + "Try restarting the application.");
            } else if (result == blackberry.push.PushService.CREATE_SESSION_NOT_DONE) {
                alert("Error: Called launchApplicationOnPush without an " +
                "existing session. It usually means a programming error.");
            } else {
                alert("Error: Received error code (" + result + ") after " + "calling launchApplicationOnPush.");
            }
        }
}

function launchApplicationCallback(result) {
    if (result == blackberry.push.PushService.SUCCESS) {
                alert("successful Configuration");
        } else {

            if (result == blackberry.push.PushService.INTERNAL_ERROR) {
                alert("Error: An internal error occurred while calling launchApplicationOnPush. " + "Try restarting the application.");
            } else if (result == blackberry.push.PushService.CREATE_SESSION_NOT_DONE) {
                alert("Error: Called launchApplicationOnPush without an " + "existing session. It usually means a programming error.");
            } else {
                alert("Error: Received error code (" + result + ") after " + "calling launchApplicationOnPush.");
            }
        }
}

function onSimChange() {
    alert("SIM card is changed!");
}

function createChannelCallback(result, token) {
    if (result === blackberry.push.PushService.SUCCESS) {
        alert("channel created");
    } else if (result === blackberry.push.PushService.INTERNAL_ERROR) {
        alert("channel failed");

    }
}

function onInvoke (invokeRequest) {
        if (invokeRequest.action != null && invokeRequest.action == "bb.action.PUSH") {
            if (pushService == null) {
                setTimeout(function() { onInvoke(invokeRequest); }, 750);
            } else {
                var pushPayload = extractPushPayload(invokeRequest);
                pushNotificationHandler(pushPayload);
            }
        }
}

function pushNotificationHandler (pushpayload) {
    var contentType = pushpayload.headers["Content-Type"];
    if(!contentType) {
        contentType = pushpayload.headers["content-type"];
        if(!contentType) {
            contentType = "text/plain";
        }
    }

    db.transaction(
        function(tx) {
            tx.executeSql("INSERT INTO Data (title) values(?)", [ "PUSH"], null);
        });

    //alert("PUSH RECEIVED");
    pushpayload.acknowledge(true);

};

I call following functions thanks to a button:

1 createPushService();

2 pushService.createChannel (createChannelCallback);

and I get a 'alert ("channel created");"and it means to me that the PushService and the channel was created successfully.

Given that I have create an event for a 'called' via 'blackberry.event.addEventListener ("called" onInvoke),"the"onInvoke"function should be called when receives a new thumb. Fix?

Unfortunately it does not work and I get no response or error.

Any help or advice is appreciated. I'm really stuck here...

The best

bert2002

Hello

A couple of things to ask you.  Not sure if they are related to your problem, but it's worth a shot.

1. you call extractPushPayload below when dealing with a thrust to invoke.  But, when this function is defined?  You must call pushSevice.extractPushPayload somewhere.

2. you should not the setTimeout function need more if you add the event listener for the "called" event in your call to success blackberry.push.PushService.create.  Our sample no longer use setTimeout.

3. in your code, you call launchApplicationOnPush and createChannel every time.  You only really need to call them once.  After graduating launchApplicationonPush and reminders of createChannel successfully the first time, then you are ready to receive the impulses.  You just do it again if you make a destroyChannel somewhere.  Do you need to call blackberry.push.PushService.create each time however.

4. are you setting the tag in your config.xml file?

Hope that helps,

Matt

Tags: BlackBerry Developers

Similar Questions

  • Disabling push client AnyConnect

    Hello

    We DO NOT get the Anyconnect client automatically. Can someone help me on how to disable this feature?

    Thank you

    Dave

    In group policy, you can configure AnyConnect request to confirm it downloads automatically, or you can also set the default value to be redirected to the web portal only, not download AnyConnect client.

    Command under Group Policy:

    AnyConnect ask no webvpn default

    --> means, it will not download or ask the user to download, and by default would be the ssl of webvpn portal.

    Here is the command for your reference:

    http://www.Cisco.com/en/us/docs/security/ASA/asa84/command/reference/A2.html#wp1743347

    I hope this helps.

  • Invoke WebWorks app in the background

    Hello

    I develop an application that must call another application I created. The application that should then be called to start a task update that updates its data in the database. I don't want my application called to be visible to the user. Is this possible? Otherwise, what's my alternative?

    I posted a sample here for opening discussion pushes client-side. Let me know if you have any questions.

    http://supportforums.BlackBerry.com/T5/Web-and-WebWorks-development/client-side-push-Inititator/TD-p...

    EDIT: The receiver push aside customer would be the work in the usual way.

    https://github.com/BlackBerry/BB10-WebWorks-samples/tree/master/pushCapture

  • Push the web application through UrbanAirship

    I want to use the urban airship to send notifications of type push to a web application. I found an example on https://github.com/blackberry/Cascades-Community-Samples/tree/master/UrbanAirshipClient but it is an application c / c++. Is it possible to grow a web application via urban airship?

    Hi, it is possible.

    Urban airship servers simply push Push BlackBerry servers that relay this push to the end-user device. This means that the only extra step that is really needed is, when registering with the push service, to register as urban airship witih as well as the link between urban airship, Push BlackBerry server and end-user device exists.

    Registration for the Push Service is essentially the same. You must create a PushService object:

       blackberry.push.PushService.create(
            {
                invokeTargetId: INVOKE_TARGET_ID,
                appId: BLACKBERRY_PUSH_APPLICATION_ID,
                ppgUrl: BLACKBERRY_PUSH_URL
            },
            createPushServiceSuccess,
            createPushServiceError,
            simChangeCallback,
            pushTransportReadyCallback
        );
    

    On createPushServiceSuccess, you create the channel by the usual method.

    /* We created the PushService instance. */
    function createPushServiceSuccess(service) {
        /* Store our PushService object. */
        pushService = service;
    
        /* ...other actions here potentially... */
    
        /* Create channel to receive pushes. */
        pushService.createChannel(createChannelCallback);
    }
    

    And finally, on the creation of the channel, we will register with urban airship.

    /* When a channel is attempting to be created, this will trigger. */
    function createChannelCallback(result, token) {
        var xhr;
        if (result === blackberry.push.PushService.SUCCESS) {
            /* On success, we'll register with Urban Airship. */
            xhr = new XMLHttpRequest();
            xhr.open('PUT', HTTPS_GO_URBANAIRSHIP_COM_API_DEVICE_PINS + token, true);
            xhr.onload = function () {
                console.log('Urban Airship: ' + this.response);
            };
            xhr.setRequestHeader('Authorization', 'Basic ' + URBAN_AIRSHIP_APPENCODED);
            xhr.send();
        } else {
            console.log('createChannelCallback: ' + result);
        }
    }
    

    Above, we will ensure that the channel was created successfully. The xhr request is purely related to urban airship and is the extra piece that we need. We use a few defined constants (previously).

    • HTTPS_GO_URBANAIRSHIP_COM_API_DEVICE_PINS is a string matches the URL of urban airship registration default PIN.
    'https://go.urbanairship.com/api/device_pins/'
    

     

    • URBAN_AIRSHIP_APPENCODED is a combination of two other channels; coded using window.btoa ().
    window.btoa(URBAN_AIRSHIP_APPKEY + ':' + URBAN_AIRSHIP_APPSECRET);
    
    • URBAN_AIRSHIP_APPKEY and URBAN_AIRSHIP_APPSECRET are obtained from urban airship console when you configure your application as follows.

    Finally, the last piece, you need to do is provide your credentials to Push BlackBerry in the console of airship urban itself. It is important to use the full URL including your CPID when you fill out this information. This is information which is sent to you by BlackBerry when you sign up for credentials EVAL or PROD.

    Beyond that, the implementation of the push, summoning, etc. would be all follow the regular WebWorks Push Application structure.

  • Several Question about Push Service

    Hi I am just learning the concept of Service Push on BlackBerry

    I have several question on initiator to push:

    -If there are a lot of app activate push (client), can push initiator must send request message (for the customer)?, or Push initiator must send for each customer (so should send 10 times so have 10 client)?

    There's a ceiling / push message max can send daily (free)? I intend to send message 3 to 5 a day

    -Is there a max client limit / receiver (on free)? What about 1,000,000 customer

    -Can I send ads or promotion on push message?

    Thank you

    Hello

    Grand tour of questions, I'll do my best address:

    (1) are you referring to multiple devices or multiple different applications? I'll answer both:

    Features: A push message can be sent to one or more devices. So, you can send a surge of broadcast to all registered devices.

    Applications: Push accounts don't support a single application, there is a 1:1 relationship. You can, however, apply to many accounts to push. We have some suppliers with dozens of accounts.

    (2) push is only offered as a free service today. There are daily caps imposed, but these caps can be * very * flexible (we can always increase your cap if necessary).

    (3) there no limit to how many customers once your account grow flies over to the production server. For the test, we need each account to start pushing the testing server which limits the number of users at 50.

    (4) at present there is no restrictions on the content of the payload to push. We do not recommend an option to allow users to not receive messages however push.

  • Why should client re-register when sim card is changed?

    Maybe this is a stupid question. I'm just curious to know who.

    I checked the push client sample app to push SDK. It seems that the registry procedure, the cient enough to send the identification number to the server. so has nothing to do with the sim card. My question is why have to re-register when changed the SIM card?

    y at - it report any with * beep * between Sim and PIN?

    Thank you!!

    PIN

    Personal identification number

    A PIN code is a unique number that identifies a BlackBerry smart phone for GSM and GPRS networks. It is printed on the label on the back of the device under the battery.

    SIM

    Subscriber identity module

    A SIM card is a smart card that identifies the Subscriber, service provider and mobile phone number. It is inserted in the device.

    Not all wireless networks use SIM cards (for example, CDMA does not work).

    In general, Désenregistrez is important if the user of this device does not want to receive push messages. For example, if they delete the application without successfully a unregister then push future messages will be sent to the device but just never displayed because there is no application listening for the push - this can incur unintended data charges. So it is always a good practice to ensure a user is unregistered successfully.

    Specifically in the context of the swap SIM on a device, let's say you have username = Foo on device PIN = 12345678 registry successfully both Push BlackBerry Service and the content provider. Now the user Foo gives the device a friend with username = Bar. Bar put in SIM card and start the unit. The application should make sure that this username = Foo is first of Nations United-registerd with the content provider. And then username = Bar should register with the content provider. From the point of view Service Push BlackBerry cancel registration is not vital because Service Push BlackBerry knows only that the PIN = 12345678 is subscribed, they do not know Foo or Bar.

  • Push not configurable Message after a device reboot java BB

    Hi all

    I joined the BlackBerry push notification successfully in my application of the Sub http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Simplified-BIS-Push-client-sample...url. Here again successfully able to get push until you restart the device notification, after restarting the device I can't able to get push notification.

    Note: I put the other entry point, checked the "-autorun at startup" and my main method is as below

     if (args != null && args.length > 0 && args[0].equals("autostart")) {
                 // auto start, wait for OS
                while (ApplicationManager.getApplicationManager().inStartup()) {
                   try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                }
    
                PushAgent agent = new PushAgent();
                agent.register();
                agent.enterEventDispatcher();
    
            } else {
    
                            theApp = new MyApp();
                theApp.enterEventDispatcher();
    
            }        
    

    Is I used something wrong or I have to put in any other place?

    Thanks @gbeukeboom. Finally, I found the solution from this link. http://rincethomas.blogspot.in/2012/07/push-notification-in-BlackBerry.html

  • recording programmed with BPA on the client sample application

    I'm trying to register my device (example of customer installed app) and I'm trying to register and unregister...

    Unfortunately, when I submit my credentials and try to register with BPA, I got:

    java.lang.Exception: registration rejected by BPA

    I have had this on the application log:

    Rc = 200 HTTP response

    Recording programmed with BPA

    Push the status API callback: failure

    Command 'register' failed with the error: java.lang.Exception: recording with BPA has been rejected by the server

    It happens more often...

    What do I have to wait until the BPA accepts my registration? How long is it?

    I don't get what want to be...

    in my BB Debug Portal my device shown as being ACTIVE but in PPG UNSUBSCIRBE

    I use this BPA URL: http://pushapi.eval.blackberry.com

    should we build a Manager to solved this problem if want to build push own app, which is an easy to use?

    Well, the problem is already solved...

    I try to record using HttpConnection BPA and it still works and I got the answer correctly...

    In the sample application customer it use the API to push record and especially it did not work (do not register correctly)...

    may I suggest to those who are faced with the problem of sam me... you can try the simplified BIS press http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Simplified-BIS-Push-client-sample...

    It works very well on me!

  • To some specific devices push notification is sent

    Hi, guys!

    I implement notifications of type push client-side using net.rim.blackberry.api.push. As far as I understand, there is no way to pass data to the device, or to a particular user at registration (I mean registerApplication() in PushApplicationRegistry) so my push initiator will not be able to send notifications only to some specific devices, not at all registered with the application id given. Is this fair?

    On the other hand, I know that using the server-side net.rim.pushsdk library, I can indicate some addresses to which notification will be sent. They are stored in the PushMessageControl instance that is passed to the net.rim.pushsdk.pap.PapServiceImpl.push () method. Could you please explain me what are these addresses and how do I send their customer when registering for notifications?

    Or maybe I am totally lost in all of this...

    Thanks in advance

    Hi Valera,

    Here is a simple code to push to BIS.

    List = new ArrayList ()addresses;

    Addresses.Add ("27f45fc5");

    PushMessageControl pushMessageControl = new PushMessageControl (idGenerator, APP_ID, addresses);
    Content content = new TextContent (data);
    PapService papService = new net.rim.pushsdk.pap.PapServiceImpl ();
    Properties PushSDKProperties = getProperties();
    HttpClientImpl client = new HttpClientImpl();
    client.setPushSDKProperties (properties);
    papService.setHttpClient (customer);

    papService.setPushSDKProperties (properties);
    PushResponse response = papService.push (APP_ID, password, APP_ID, pushMessageControl, content);

    Just add the pins you want to send to in the address list.

    HTH

    Chris

  • Push registration: (Berr java.lang.IllegalArgumentException) network error

    Hello

    We try to get WebWorks push the work but are a problem with blackberry.push.openBISPushListener. The onRegister function returns a status of 1 (network error).

    The log file shows the following:

    11/9 10:00:54 W net.rim.blackberry.api.push - Berr java.lang.IllegalArgumentException
    11/9 10:00:21 a Contapp - PushDaemon is started.
    11/9 10:00:21 a Contapp - Register push application
    11/9 10:00:21 a Contapp - open BIS push listener
    

    This application is used to work so I wonder if something might have changed in the upgrade of the server push.

    The application code is the following:

    
    
    
        
    
    
        

    And the following push configuration in the config.xml file:

    
    
    
    
    
    
    
    
    
      BIS-B
      MDS
      TCP_WIFI
      TCP_CELLULAR
      WAP2
      WAP
    
    
    
      read_device_identifying_information
      access_shared
    
    

    It is all tested on a device 9300.

    Any ideas as to why we get this error?

    Thanks in advance for the help!

    Nick

    This issue should now be resolved, please let me know if you continue to have problems with the registration with the EVAL server.

  • Need example of application on push notifications

    Hello

    Can someone give me some example code snippert to create notifications of type push on both Client and server...

    BES push is included as a sample in eclipse + plugin

    to BIS-push, I wrote a simplified example that you can find in the KB or the forums to push

    http://supportforums.BlackBerry.com/T5/BlackBerry-push-development/sample-code-for-client-software-s...

    the article is here:

    http://supportforums.BlackBerry.com/T5/BlackBerry-push-development/simplified-bis-push-client-sample...

  • API of Communication OS6 no Msg Push

    I'm just trying to provide 2 versions diff to push Clients:

    * OS 5 customer (based on the sample of push and Simon_Hains code example)

    works well

    * OS 6 Client using the new API of Communication Communication API demo

    Subscription to the content provider and recording of BPS works well: questioning the BPS, the customer is active

    Removal of the device APP automatically off records the PIN of the BPS Server

    The SubscriptionResponseListener works as well: onMessage receives the response from the ContentServer to verify if the subscription is allowed.

    But: the MessageListener for PushMessages of BPS gets no message. The messages will become "EXPIRE" after a while because of the delivery-before-timestamp...

    The Messages were repelled EVAL Push server if you use the OS5 - sample of push.

    also if PushSample is running and you try to run also the OS6 push Cklient I have the correct message that another receiver is already listening on the Port.

    think there must be something wrong with my receiver not to receive Messages - maybe the URI of the receiver is listening on:

    BPS_PUSH_RECEIVER_URI = ' local: / /: "+ BPS_PUSH_PORT".

    the JavaDoc says:

    createNonBlockingReceiverDestination will receive the messages by listening to the local://deviceAppName URL.

    the API of Communication demo uses:

    local: / /:tro-No./test2

    I also tried to add the receiver URI/name-of-cod, but it's the same: no message coming

    any ideas what could be the problem?

    GOD wrote:

    ...

    think there must be something wrong with my receiver not to receive Messages - maybe the URI of the receiver is listening on:

    BPS_PUSH_RECEIVER_URI = ' local: / /: "+ BPS_PUSH_PORT".

    the JavaDoc says:

    createNonBlockingReceiverDestination will receive the messages by listening to the local://deviceAppName URL.

    the API of Communication demo uses:

    local: / /:tro-No./test2

    thx for helping RIM on that: a ' / ' missing

    This is the URI of the BPSPushReceiver of the OS 6 Communication API is listening on:

    "local: / /:" + BPS_PUSH_PORT +"/" ".

  • Examples of Code for the (Simplified) Client software

    After digging through the application of the whole sample RIM provides I thought I want to provide a code for the simplified example. Short opinion: post connection suffix is not allowed on the forums. You can see the sample application of the RIM if you do not already elsewhere. Please see the article here, it's under review if you want to contribute (although the code is mainly in the attached files): http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Simplified-BIS-Push-client-sample...

    the article has been published: http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Simplified-BIS-Push-client-sample...

  • WebWorks 10 - launch Variables

    Is there a global variable of BB 10 Webworks differntiates between when a user or an onInvoke (push notification) launches the app?

    The problem is I want to exit the application when a push notification is received and processed.

    I don't want to leave the app when a user launches and receives a push notification.

    I think that a single variable availble in the bb platform doing it, but am not sure, I have not found anything concrete in the documentation.

    Thank you

    Hi pzill4,

    When it is called with a push notification, the blackberry.invoked method fires, so you can get out of here:

    blackberry.event.addEventListener("invoked", onInvoked);
    

    Check the example in the: https://developer.blackberry.com/html5/apis/blackberry.invoked.html#.event: call

    Blog here: http://devblog.blackberry.com/2012/08/blackberry-10-webworks-push-app/

  • maddening problem Push

    Hi all

    My application is running on a curve and "BOLD", OS v5.0.0.973/979.  I'm trying to register to receive Push notifications and his failling.

    I have the code to save running in its own thread, here's the run() method:

    public void run() {}

    ApplicationDescriptor ad = ApplicationDescriptor.currentApplicationDescriptor ();

    int port = Port Push email for registration of production;

    String appId = "email of record production ApplicationID.

    String bpasUrl = 'Email of record production PPG Base URL';

    serverType bytes = PushApplicationDescriptor.SERVER_TYPE_BPAS;

    Cushion PushApplicationDescriptor = new PushApplicationDescriptor (appId,

    port, bpasUrl, serverType, ad);

    PushApplicationStatus pushApplicationStatus = PushApplicationRegistry.getStatus (pad);

    pasStatus bytes = pushApplicationStatus.getStatus ();

    if (pasStatus is PushApplicationStatus.STATUS_ACTIVE) {

    Connect ('PUSH already registered');

    } else If (pasStatus == PushApplicationStatus.STATUS_PENDING) {}

    Log ('recording standby PUSH');

    } else {}

    try {

    PushApplicationRegistry.registerApplication (pad);

    }

    catch (IllegalArgumentException iae) {

    log ("Error");

    }

    }

    }

    I have tried from this thread from 2 different places in my class that I have defined as:

    public Class MyApp extends UiApplication implements PushApplication

    I tried it from MyApp constructor and a method after of

    enterEventDispatcher() is executed.

    It takes to grow a record in a separate Thread?  I've seen examples where push record is made from UiApplication and those where its done in a different Thread.  Is how important it?

    I understand that I can not post the actual values of the email of record production, but I used enamel line labels in the section titled:

    I got it fixed, but almost by accident.

    I started to wonder if I have a method for registration of HttpConnection based would be more appropriate than the PushApplicationRegistry method I used.  At least half of the examples out there do not use PushApplicationRegistry.

    So I started to reimplement my method of registration based on PushAgent.java I found here: http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Simplified-BIS-Push-client-sample...

    I noticed that it added "mss/PD_subReg" to the url.  As I had nothing to lose, I added "mss/PD_subReg" to the url that I got from RIM confirming the displacement of our application in production.  Has been in a section titled "Request credentials (to use in your client application)" and was labeled "PPG Base URL."

    The * is a note saying his reserved production.

    All started to work just fine right there.

    I'm just curious, I spent a day combing through the documentation and could not find any references to this outside the sample program on the link I posted.  Anywhere else I could look?

Maybe you are looking for

  • BIOS password removal

    I have a Compaq mini 110 who crashes at startup and wrote Enter the current password now: After 3 entries, it stops with serial #[edited by Moderator] Please help me.

  • Re: Satellite M100 is overheating

    Hello, I m having problem wit a little overheated about it. When using normally it runs hot but the time where I start the game in a bout 10 min it shuts off and burns upward. I ve kept the fan clear nothing of blocking the side, he s in a cool place

  • Delete the music purchased from my Iphone

    I have an iPhone 16GB 6 and much more of 16GB of music on my MacMini so I use "Selected playlists, artists, etc." to synchronize some of my music on my phone but lately, I've noticed that some artists and other things are still popping up even if the

  • TouchSmart 520 - screen blocked after the darkening of the screen

    Hello, first my OS is win 7 and I'm the Turkey but I couldn't find any Forum Hp Turkish so I'm here. I arranged my power setting, more close to the screen after 5 minutes, normally it works perfectly, but now his blocking, I meet 2 or 3 times; screen

  • "Reference to the error object not set to an instance of an object."

    Why after an automatic update of windows 7, I get this error "error object not set to an instance of an object reference"?