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
Developer
Posts: 27
Registered: ‎02-22-2010
My Device: Password
Accepted Solution

blackberry.identity.uuid and WebWorks On Z10 = undefined?

Hello,

 

I'm trying to get the UUID / PIN. All I get is undefined on the Z10 when I run it. I can't seem to figure out why. I think I  have all the required components for it to work correctly. 

 

My code looks like this:

 

<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1"> 
        <title>MY APP</title>
        <link rel="stylesheet" href="./jquery/jquery.mobile-1.3.0/jquery.mobile-1.3.0.min.css" />
      
        <script src="./jquery/jquery-1.8.3.min.js"></script>
        <script src="./jquery/jquery.mobile-1.3.0/jquery.mobile-1.3.0.min.js"></script>
        <script type="text/javascript" src="http://www.blackberry.com/app_includes/asdk/adBanner.js"></script>
        <script src="local:///chrome/webworks.js" type="text/javascript"></script>

        <script type="text/javascript">
var dHeight=window.innerHeight;
            var dWidth=window.innerWidth;
            var uuid =  null;
            alert(uuid);
            try{
                   
                $(document).ready(function(){
                
                    try{
                    uuid = blackberry.identity.uuid;
                    }catch(err){alert(err.message);}
                    alert(uuid);
                });
            }catch(eee){}


</script>
    </head>

    <body style="padding: 0;margin: 0">
<div>HELLO WORLD</div>
</body>
</html>

My config.xml looks like this:

 

<?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.1" id="myapp" xml:lang="en"
       
>
   
    <name>MYAPP</name>
    <icon src="images/bb10/icon150.png"/>
    <content src="bb10.html" rim:allowInvokeParams="true"/>
    <rim:orientation mode="auto"/>
    <rim:splash src="images/bb10/splash1280x768.png"/>
    <rim:splash src="images/bb10/splash768x1280.png"/>    
    <access subdomains="true" uri="*"/>
    
    
    <rim:permissions>
        <rim:permit>read_geolocation</rim:permit>
        <rim:permit>read_device_identifying_information</rim:permit>
        <rim:permit>access_shared</rim:permit>
           
    </rim:permissions>
    
    <feature id="blackberry.app" required="true" version="1.0.0.0">
          <param name="websecurity" value="disable" />
    </feature>
     <feature id="blackberry.identity" required="true" version="1.0.0.0"/>
    <feature id="blackberry.app.event" required="true" version="1.0.0.0"/>
    <feature id="blackberry.system" required="true" version="1.0.0.0"/>
    <feature id="blackberry.system.event" required="true" version="1.0.0.0"/>
    <feature id="blackberry.ui.dialog" required="true" version="1.0.0.0"/>
    <feature id="blackberry.utils" required="true" version="1.0.0.0"/>

   
    <feature id="blackberry.invoke" required="true" version="1.0.0.0"/>
    <feature id="blackberry.invoke.AddressBookArguments" required="true" version="1.0.0.0"/>
    <feature id="blackberry.invoke.BrowserArguments" required="true" version="1.0.0.0"/>
    <feature id="blackberry.message" required="true" version="1.0.0.0"/>
    <feature id="blackberry.message.sms" required="true" version="1.0.0.0"/>
    <feature id="blackberry.push" required="true" version="1.0.0.0"/>

    
    
</widget>

 

 

Retired
Posts: 203
Registered: ‎12-18-2012
My Device: Z10, Q10, Q5, Z30, Z3
My Carrier: Bell

Re: blackberry.identity.uuid and WebWorks On Z10 = undefined?

Hi,

 

You need to wait for the webworksready event to fire.

Bryan Higgins
BlackBerry WebWorks
@bryanhiggins
Developer
Posts: 27
Registered: ‎02-22-2010
My Device: Password

Re: blackberry.identity.uuid and WebWorks On Z10 = undefined?

Thanks for the quick response. 

 

I still have no luck getting it to work. I added a listener:

            window.addEventListener("load", function(e) {
                document.addEventListener("webworksready", function(z){
                    alert(blackberry.identity.uuid);
                    
                });
            }, false);

 Still it never fires up. Any idea as to why?

 

For the record, jquery events fire up nicely no problem but I still can't access any of the webworks API.

 

Thanks

 

 

Developer
Posts: 817
Registered: ‎11-19-2009
My Device: Z10, Q10, 9900, 9790, PlayBook,
My Carrier: T-Mobile UK, Three, O2, Orange, Sunrise, Swisscom

Re: blackberry.identity.uuid and WebWorks On Z10 = undefined?

[ Edited ]

Did you upload your app in debug mode to see if you didn't get any errors?
It could be that something failed to load and just stopped the script.

 

EDIT: Just read the other thread and it seems that the problem lies with the advertising API not being ready yet... Smiley Sad

--
Olivier - interfaSys ltd
Developing for BlackBerry 10 devices using the Sencha Touch framework.
Highlighted
Developer
Posts: 27
Registered: ‎02-22-2010
My Device: Password

Re: blackberry.identity.uuid and WebWorks On Z10 = undefined?

Hello,

 

I finally figured it out. 

 

My app relies on :

- jquerymobile (1.3.0) and jquery 1.8.3.  I'm not sure if it has an impact or not but I thought I'd share anyway.

 

For some reason, it is fine to put all of my scripts in the <HEAD> of my html document on Chrome running Ripple.

 

However, on the BB Z10, it doesn't seem to be able to see/execute the following line from the <HEAD> tag : <script type="text/javascript"></script>

<script src="local:///chrome/webworks.js" type="text/javascript"></script>

 Looking through the examples I realized that it was part of the <BODY> tag. By moving the script from <HEAD> to <BODY> gave me access to all of the webworks API right away.

 

I tested blackberry.identity.uuid and managed to generate an alert of the PIN right away.

 

I hope this post might help someone else in the future as simple as it might be Smiley Happy

 

Thanks