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
BB_shi
Posts: 89
Registered: ‎03-15-2011
My Device: Blackberry 9800
My Carrier: developer

Blackberry WebWorks 2.0 Beta PIM Contacts not working

Hi All,

 

I am trying to run PIM contacts and Invocation sample for BB10.However facing issues and it's showing white screen only.

Below is the link from from where i have downloaded sample:

Invocation Sample Link:

https://github.com/blackberry/BB10-WebWorks-Samples/tree/WebWorks-2.0/Invocation

PIM contact Link:

https://github.com/blackberry/BB10-WebWorks-Community-Samples/tree/WebWorks-2.0/pimcontacts

 

We have done required changes as mentioned in below link:

https://developer.blackberry.com/html5/documentation/beta/coding_differences.html

 

Able to build and install app on my BB z10 device.

I think issues is related to cordova.It's not calling native apis as per given in required sample js.Tried to debug code through alert.

In invocation sample, it going befor blackberry.invoke.invoke.After it's not showing up alert.

So, might be problem with cordova path.

Below is config.xml for my PIM contact  sample project:

 

<?xml version="1.0" encoding="UTF-8"?>

<!--
* Copyright (c) 2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
-->

<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0.0"
id="webworkspim"
xml:lang="en">

<!-- Application details. -->
<name>PIM Contacts</name>
<author>Research In Motion</author>

<!-- Application startup page. -->
<content src="index.html"/>

<!-- Application icon. -->
<icon src="appicon.png" />

<!-- Allow access to external URLs. -->
<access uri="*" subdomains="true" />

<!-- Do not cache content. -->
<rim:cache disableAllCache="true" />

<!-- Focus-based navigation for BBUI.js. -->
<rim:navigation mode="focus" />

<!-- Required permissions. -->
<rim:smileytongue:ermissions>
<rim:smileytongue:ermit>access_pimdomain_contacts</rim:smileytongue:ermit>
</rim:smileytongue:ermissions>

<!-- Required features for BBUI.js. -->
<feature id="blackberry.app" />
<feature id="blackberry.ui.dialog" />

<!-- Additional features. -->
<feature id="blackberry.pim.contacts" />
</widget>

 

Please help.It's very urgent.

 

Thanks in advance:smileyhappy:

 

 

 

 

Please use plain text.
Administrator
astanley
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Blackberry WebWorks 2.0 Beta PIM Contacts not working

Have you added the necessary plugins to your project?  For the example you have provided, you would need to run the following commands from the app project folder:

 

webworks plugin add com.blackberry.app
webworks plugin add com.blackberry.invoke
webworks plugin add com.blackberry.ui.dialog
webworks plugin add com.blackberry.pim.contacts

Remember to add the invoke plugin.  I see you mention that in your debugging, but I don't see it listed in config.

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Please use plain text.
Developer
BB_shi
Posts: 89
Registered: ‎03-15-2011
My Device: Blackberry 9800
My Carrier: developer

Re: Blackberry WebWorks 2.0 Beta PIM Contacts not working

Hi astanley,

 

I run all these commands on command prompt. when i run 

webworks plugin add com.blackberry.pim.contacts

It is showing error :

{ [Error: connect ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'co
nnect' }

 

But when i check plugins folder, all plugins are there.

 

Now i am trying to use CustomPickerOptions in my app but it's showing white screen only.

 

For this i created a sample app in webworks 2.0 beta and then did changes in config.xml and index.html. And added all plugins as you suggested.

 

Find below my code for config.xml:

<widget id="TestNew" version="0.0.1" 
xmlns="http://www.w3.org/ns/widgets" 
xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>TestNew</name>
<description>A sample Apache Cordova application that responds to the deviceready event.</description>
<author email="" href="">companyname</author>
<content src="index.html"/>
<access origin="*"/>
<!-- Required permissions. -->
<rim:permissions>
<rim:permit>access_pimdomain_contacts</rim:permit>
</rim:permissions>
<preference name="fullscreen" value="true"/>
<preference name="webviewbounce" value="true"/>
</widget>

 

 

 

index.html:

 

<!DOCTYPE html>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <title>Hello World</title>
    </head>
    <body>
        <div class="app">
            <h1>Blackberry Webworks</h1>
            <div id="deviceready" class="blink">
                <p class="event listening">Connecting to Device</p>
                <p class="event received">deviceready</p>
            </div>
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript">
            app.initialize();
        </script>
		<script type="text/javascript">
			alert('Test app----2222');
			var contacts = blackberry.pim.contacts,
			ContactPickerOptions = contacts.ContactPickerOptions;
			alert('Test app----3333');
			invokeContactPickerSingle();
			function onCancel() {
				alert("User pressed cancel in contact picker.");
			}

			function onInvoke(error) {
				if (error) {
					alert("Error invoking contact picker: " + error.code);
				} else {
					alert("Contact picker invoked!");
				}
			}

			function onContactSelected(data) {
				alert("Id of selected contact: " + data.contactId);
			}

			function onContactsSelected(data) {
				alert("Total # contacts selected: " + data.contactIds.length);
			}

			function onContactAttributeSelected(data) {
				alert("The selected field '" + data.field + "(" + data.type + ")' has value '" + data.value + "' belongs to contact with id: " + data.contactId);
			}

			function invokeContactPickerSingle() {
				contacts.invokeContactPicker({
					mode: ContactPickerOptions.MODE_SINGLE,
					fields: ["phoneNumbers"]
				}, onContactSelected, onCancel, onInvoke);
			}

			function invokeContactPickerMultiple() {
				contacts.invokeContactPicker({
					mode: ContactPickerOptions.MODE_MULTIPLE,
					fields: ["phoneNumbers"]
				}, onContactsSelected, onCancel, onInvoke);
			}

			function invokeContactPickerAttribute() {
				contacts.invokeContactPicker({
					mode: ContactPickerOptions.MODE_ATTRIBUTE,
					fields: ["phoneNumbers", "emails"]
				}, onContactAttributeSelected, onCancel, onInvoke);
			}

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

 

After launching this app on device it is not showing alert 'Test app----3333'.

 

ContactPickerOptions.js.js file is available at

%HOME_PATH%WebWorks Projects\TestNew\plugins\com.blackberry.pim.contacts\src\blackberry10

 

What i am missing. The api "blackberry.pim.contacts " is not getting called.

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,541
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Blackberry WebWorks 2.0 Beta PIM Contacts not working

The way you've defined your second <script> in the previous post is going to cause issues.

 

<script type="text/javascript">
    app.initialize();
</script>
<script type="text/javascript">

Specifically the <script> (and all of its contents) that are in bold.

 

This script will execute when index.html is loaded, meaning that the document may not be loaded yet, blackberry is still likely undefined, and the deviceready event hasn't fired.

 

This is an issue because you are directly calling blackberry APIs, example:

 

var contacts = blackberry.pim.contacts,

You will need to wait until after deviceready fires. In the standard WebWorks 2.0 project that is created, there should be an index.js file that is created that implements these APIs for you, and you can either run this code inside of onDeviceReady, or integrate with the receivedEvent function to wait for the deviceready id, and only then should you be running blackberry (or even APIs that require document) code.

 

The script itself will be failing since blackberry does not exist yet. Causing script execution to stop, so there will be no alert, and you will only have a white-screen (since execution does not continue.)


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
Rishabh_Jain
Posts: 101
Registered: ‎07-11-2011
My Device: 8900
My Carrier: Airtel

Re: Blackberry WebWorks 2.0 Beta PIM Contacts not working

I am also facing same issue.When i am trying to add pim contact extension getting arror as follows:

{ [Error: connect ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'co
nnect' }

After analysing the structure, it's adding required pim contact pugin inside plugin folder.But it is not adding required plugin name inside blackberry 10 json file.

Please suggest where i am doing wrong.

 

However, i have tried using pim contact plugin from earlier Blackberry Webworks 1.0 version.Able to use it.Packing and Bulding the app through ripple emulator.I am opening the contact picker.Now, i want it to select single contact and want retrive all fields value(Name, Phone Number, Image) of selected contact.Through single mode attribute able to get id of selected contact.Then calling getcontactbyID(contact.ID).It taking too much time to retrive the result.Also, i am blae to get contact.name.givenName.

Now i want to retrive all values realated to contact(name, phone number and photo).

If anyone has done this, please provide me sample code for same.

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,541
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Blackberry WebWorks 2.0 Beta PIM Contacts not working

Can you please share the full command-line output you are seeing? (including the command you are running, and the resulting output.) A screenshot would be ideal.

Mixing the new Cordova and old WebWorks approach is not recommended.

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
Rishabh_Jain
Posts: 101
Registered: ‎07-11-2011
My Device: 8900
My Carrier: Airtel

Re: Blackberry WebWorks 2.0 Beta PIM Contacts not working

Thanks for your prompt response.

I am not mixing the new cordova and old WebWorks.

Actaually, when i was not able to get succeded on WebWorks Beta 2.0 version(Using PIM Contact PluGin), i  jumped over to WebWorks 1.0(Previous Version) and build & packaging  my sample code through old SDk only, using keyStore password and Riple emulator.In which, i am able to use pim.contact plugin coming with BB WebWorks SDK 1.0.This one thing.

 

Now, when i am working with Blackberry WebWorks Beta Version, i am not bale to get through it.Following is the screen shots for same:

 

PluginErr.png

 

Also, content of the  blackbery10 file is as follows:

{"prepare_queue":{"installed":[],"uninstalled":[]},"config_munge":{"www/config.xml":{"/widget":{"<feature name=\"com.blackberry.app\" value=\"com.blackberry.app\" />":1,"<feature name=\"com.blackberry.invoke\" value=\"com.blackberry.invoke\" />":1,"<feature name=\"com.blackberry.ui.dialog\" value=\"com.blackberry.ui.dialog\" />":1,"<feature name=\"PGLowLatencyAudio\" value=\"PGLowLatencyAudio\" />":1,"<feature name=\"com.blackberry.io\" value=\"com.blackberry.io\" />":1}}},"installed_plugins":{"com.blackberry.app":{"PACKAGE_NAME":"TestNew"},"com.blackberry.invoke":{"PACKAGE_NAME":"TestNew"},"com.blackberry.ui.dialog":{"PACKAGE_NAME":"TestNew"},"PGLowLatencyAudio":{"PACKAGE_NAME":"TestNew"},"com.blackberry.io":{"PACKAGE_NAME":"TestNew"}},"dependent_plugins":{}}

 

As per my understanding it''s not adding required plugin named as "com.blackberry.pim.contacts" inside json file.Though adding the "com.blackberry.pim.contacts" inside pluging folder in my test app.

Please help me where i am doing wrong.

 

 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,541
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Blackberry WebWorks 2.0 Beta PIM Contacts not working

It may be due to a conflict in version. If I'm not mistaken, you've downloaded the Cordova plugins separately and are trying to add them from the downloaded folder, correct?

What if you try just:
webworks plugin add com.blackberry.pim.contacts

The WebWorks SDK installation comes with default plugins and will know how to access them if you try to execute just the direct command. You shouldn't need to download external WebWorks plugins.

Could you give that a shot and let us know if you still see the issues when using the WebWorks installed plugins?

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
Rishabh_Jain
Posts: 101
Registered: ‎07-11-2011
My Device: 8900
My Carrier: Airtel

Re: Blackberry WebWorks 2.0 Beta PIM Contacts not working

Thanks for your response.

Conflict in version.Didn't get it?Please clarify.But i am not downlaoding the cordova plugins seaparately.I have just copied the required plugIn named as "com.blackberry.pim.contacts" from the directory path"C:\Program Files\BlackBerry\BB10 WebWorks SDK 2.0.0.54\plugin" and paste in my local path.Then jsut trying to add the respective plugin from that path only.For which i had shown you my logs coming on my command terminal.

 

Now, i have tried to run simple command "add com.blackberry.pim.contacts" from my command terminal.(I have to navigated to the project root directory of my TestApp on to command terminal).Still facing the same issue.Below is the screenShot for same:

AddPluginErr.png

 

Please help in getting through this.

 

Also, need one more favour.I followed all instruction for setting up the tools required for complete installation of Blackberry WebWorks beta 2.0 version.It''s installed propelry.But i am not able to run it on my machine.Whereas followed the same steps on other machin e with same configuartion.It''s running fine there.Below is the link where i have posted my issue:

 

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Blackberry-WebWorks-Beta-2-0-Ins...

 

Thanks in advance.

 

 

 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,541
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Blackberry WebWorks 2.0 Beta PIM Contacts not working

I see, I thought the location may have meant the files were from elsewhere, but if they're copied from the SDK that should be fine; though technically you shouldn't need to do any copying if you just reference the APIs directly as you did in the above screenshot.

Could you try the following:

- Open your Start menu and type: uac
- Open: Change User Account Control settings
- On this page there should be a slider, bring it all the way down.
- Save the changes.

- Open your Start menu and type: cmd
- Right-click on cmd.exe and select: Run As Administrator

From this new Command-Prompt window, try the following commands:
> webworks create SampleProject
> cd SampleProject
> webworks plugin add com.blackberry.app

If the above works, please also try:

> webworks plugin add com.blackberry.pim.contacts

You can run these commands from any directory, ideally whichever folder you usually use. However the important thing is that UAC is disabled and that your Command Prompt is started in Administrator mode.

If the above still does not work, could you try executing the commands from the following folder (you may need to create it manually):
C:\webworks


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.