Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Contributor
ugalriv
Posts: 5
Registered: ‎11-06-2012
My Carrier: Bell
Accepted Solution

Can't get blackberry.invoke.invoke to work onload of page or button

Hello Everyone,

 

I hoping to find some help with blackberry.invoke.invoke.  :Helpsmilie:
I realize this is a long post , but I wanted to give as much as detail as I could. :Detective:

 

Some background:

I want to create simple wrapper app, in enssence it will show a splash scrren and then open the browser to a specific url.

I am aware, that this can be achieve via the config.xml, content tag, src attribute with the appropriate permission/access. I have tried this and it works correctly.

The wall I run into is that my app needs to be i18n.
Therefore, the URL would change depending on the language (2 languages).

Currently, via the config.xml the locale can be used for the icon, splash, it will be available for the app name on the device homescreen sometime in November (https://developer.blackberry.com/html5/download/roadmap/) but I don't see anything about the content tag being i18n....

Therefore, i've decided to take care of this in the index.html, my page will load check the device language (via blackberry.system.language), then select the corresponding URL and open the browser with the website in the correct language.

 

However, I can't get the blackberry.invoke.invoke to work not even via a button... even less once the page has finished loading  (body onLoad= openWebLinkInBrowser())...

I even tried the sample code shown here and it still doesn't work...
https://developer.blackberry.com/html5/documentation/getting_started_with_bb10_ww_sdk_2007056_11.htm...

 

Info:

webworks-1.0.2.9.js
BBos10 build 10.0.0.388 on Alpha device [Result: nothing when I click the button]

BBos10 build 10.0.0.386 on simulator [Result: nothing when I click the button]
Ripple Emulator (Beta) Ripple UI (v0.9.10) Ripple Build & Deploy (v0.9.5)  [Result: Pop-up with following message:
Requested to invoke external application with the following arguments:
target = sys.browser
uri = http://www.google.ca ]

 

Here is my Code (using google.ca for testing purposes):
config.xml

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"        
    xmlns:rim="http://www.blackberry.com/ns/widgets"        
    version="1.0.0" id="My App" xml:lang="en">  
    
 <author href="http://www.example.com/"          
     rim:copyright="Copyright 1998-2012">My cie</author>
      
 <name>My App</name>  
 <icon src="icon.png"/>

 <rim:splash src="splash.png" />
 
  <content src="index.html" type="text/html" charset="UTF-8" />
 
 <description>Wrapper app for os10</description>

 <access uri="http://www.google.ca" subdomains="true">
  <feature id="blackberry.ui.dialog"/>
  <feature id="blackberry.app"/>
  <feature id="blackberry.invoke"/>
 </access>
  

   <feature id="blackberry.identity"/> 
  <feature id="blackberry.system" />
  
  <rim:invoke-target id="ca.google">
   <type>application</type>
   <filter>
    <action>bb.action.open</action>
    <mime-type>text/*</mime-type>
    <mime-type>image/*</mime-type>
    <property var="uris" value="http://www.google.ca" />
   </filter>    
   </rim:invoke-target>
 
 <feature id="blackberry.app.orientation">
    <param name="mode" value="portrait" />
 </feature>
 
</widget>

 

Index.html
<!DOCTYPE html>
<html>
 <head>   
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
   <script src="webworks-1.0.2.9.js"></script>
 </head>
 
 <body>
  
  <input type="button" onclick="openWebLinkInBrowser();" value="Click Me2!"/>   
   
  <script type="text/javascript"> 

 

     function onInvokeSuccess() {
        alert("Invocation successful!");
     }
 
     function onInvokeError(error) {
         alert("Invocation failed, error: " + error);
     }
     
     function getDeviceLang(){
       var deviceLangRegion = blackberry.system.language.toLowerCase();
       var deviceLangRegionArray = deviceLangRegion.split("_");
       var deviceLang = deviceLangRegionArray[0]; 
               
       return deviceLang;
     }

 

     function checkConnectivity(){
       var isConnected = blackberry.system.hasDataCoverage();
       if (isConnected == false){
       alert("You need connectivity to use this application");
       blackberry.app.exit();
       }else{
        alert("CONNECTION :smileyhappy:");
        openWebLinkInBrowser();
       }
     }

 

     function getURL(deviceLang){
       var urlEN="https://www.myenglishwebsite.com";     
       var urlFR="https://www.myfrenchwebsite.com";
       var urlLang;
       
       if (deviceLang == "fr"){
        urlLang = urlFR;
       }else{
        urlLang = urlEN;
       }      
       return urlLang;     
     }

 

     function openWebLinkInBrowser() {  
           
        blackberry.invoke.invoke({
        target: "sys.browser",             
        uri: "http://www.google.ca"},             
        onInvokeSuccess, onInvokeError);     
       }  

 

     window.addEventListener("load", function(e) {        
         document.addEventListener("webworksready", function(e) {           
         checkConnectivity; openWebLinkInBrowser; getDeviceLang; }, false);
         }, false);

 

  </script>  
 
 </body>
</html>

 

Please use plain text.
BlackBerry Development Advisor (Retired)
mimendoza
Posts: 64
Registered: ‎06-04-2012
My Carrier: Bell

Re: Can't get blackberry.invoke.invoke to work onload of page or button

Did you want the OS to open a browser window after the user opens your app? Or do you want to open the URL while staying inside the WebWorks application (which is what happens when you did it through the config.xml - the first way that you tried it)

----------------------------------------------------------------------------------
- Did this post help solve the issue? Click on "Accept as Solution"
- Was the content of this post helpful? Please give it a "Thumbs Up"

developer.blackberry.com
@BlackBerryDev
Please use plain text.
New Contributor
ugalriv
Posts: 5
Registered: ‎11-06-2012
My Carrier: Bell

Re: Can't get blackberry.invoke.invoke to work onload of page or button

I wasn't even aware I could make the actual browser of the device open.

I thought the direct way via the config.xml was the only way and that blackberry.invoke.invoke would achieve the same. I'm good with it being inside the framework.

Please use plain text.
BlackBerry Development Advisor (Retired)
mimendoza
Posts: 64
Registered: ‎06-04-2012
My Carrier: Bell

Re: Can't get blackberry.invoke.invoke to work onload of page or button

Using "invoke" will allow you to open other applications, such as the browser, or camera etc.

 

For your app, you don't need to use any invocation and can simply use

 

window.location.href = "http://your.site.com";

 

to change the document that is seen in the application. Once you find the language the device is using, you can then set this property according to the URL you need and it will redirect to that URL inside your app window.

 

Hope that helps!

----------------------------------------------------------------------------------
- Did this post help solve the issue? Click on "Accept as Solution"
- Was the content of this post helpful? Please give it a "Thumbs Up"

developer.blackberry.com
@BlackBerryDev
Please use plain text.
New Contributor
ugalriv
Posts: 5
Registered: ‎11-06-2012
My Carrier: Bell

Re: Can't get blackberry.invoke.invoke to work onload of page or button

Thanks for the clarification.
Please use plain text.