Page 1 of 1

Error with Phonegap Plugin

PostPosted: Wed Feb 05, 2020 7:17 pm
by francisco.garcia
Hi, i have developed a web component service form using phonegap bluetooth serial plugin. It was working till last Servoy update.
Now i get the following error.
Error while executing client side code. Please see browser console for more info. Error: ReferenceError: Bridge is not defined

I repeat, it was working fine till the last Servoy update.
Please help.
index.html
Code: Select all
<html>
   <head>
      <meta charset="utf-8" />
      <meta name="viewport" content="width=device-width, initial-scale=1" />
      <title>
      </title>   
      <script src="phonegap.js"></script>
      <script src="cordova.js"></script>
      <script src="cordova_plugins.js"></script>      
      <script src="bridge.js"></script>
      <script src="push.js"></script>      
   </head>
   <body style="margin: 0px;background-color:#ffffff; background-image:url(img/integra7.png),url(img/loading.gif); background-position: center,50% 65%; background-repeat:no-repeat;">
      <iframe src="myurl" onload="Bridge.init(this);" height="100%" width="100%" frameborder="0" style="  display: block; width: 100vw; height: 100vh; transform-origin: top left;"></iframe>
   </body>
</html>

config.xml
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns   = "http://www.w3.org/ns/widgets"
    xmlns:gap   = "http://phonegap.com/ns/1.0"
    id          = "com.phonegap.integramobilebt"
    versionCode = "10"
    version     = "1.0.0" >
<!-- versionCode is optional and Android only -->
   <name>Integra Mobile v2</name>
   <description>
     Integra Mobile - Servoy NG
   </description>
   <author>
      Interdata Software
   </author>
   <plugin name="cordova-plugin-whitelist" />
   <plugin name="cordova-plugin-camera" spec="1.2.0" />   
   <plugin name="cordova-plugin-geolocation"/>
   <plugin name="cordova-plugin-bluetooth-serial" />
   <plugin name="cordova-plugin-device" />
   <allow-navigation href="myurl" />
    <platform name="android">
            <icon src="icon.png" width="72" height="72" density="hdpi" />
            <icon src="icon.png" width="36" height="36" density="ldpi" />
            <icon src="icon.png" width="48" height="48" density="mdpi" />
            <icon src="icon.png" width="96" height="96" density="xhdpi" />
            <preference name="Fullscreen" value="true" />
    </platform>   
   <allow-intent href="tel:*" />
   <access origin="http://*" />
   <access origin="https://*" />
   <access origin="tel:*" launch-external="yes"/>
   <preference name="loadUrlTimeoutValue" value="120000" />
</widget>

bluetoothSerial.js
Code: Select all
angular.module('idbluetoothserialIdbluetoothserial',['servoy'])
.factory("idbluetoothserialIdbluetoothserial",function($services)
{
   var scope = $services.getServiceScope('idbluetoothserialIdbluetoothserial');
   return {
      connect: function(macAddress_or_uuid, connectSuccess, connectFailure) {            
         Bridge.executeMethod(connect, null, [macAddress_or_uuid, connectSuccess, connectFailure]);

         function connect(macAddress_or_uuid, connectSuccess, connectFailure) {            
            window.bluetoothSerial.connect(macAddress_or_uuid, connectSuccess, connectFailure);
         }
      },
      list: function(success, failure) {            
         Bridge.executeMethod(list, null, [success, failure]);

         function list(success, failure) {            
            window.bluetoothSerial.list(success, failure);
         }
      },
      write: function(data, success, failure) {            
         Bridge.executeMethod(write, null, [data, success, failure]);

         function write(data, success, failure) {            
            window.bluetoothSerial.write(data, success, failure);
         }
      },
      isConnected: function(success, failure) {            
         Bridge.executeMethod(isConnected, null, [success, failure]);

         function isConnected(success, failure) {            
            window.bluetoothSerial.isConnected(success, failure);
         }
      },
      isEnabled: function(success, failure) {      
         Bridge.executeMethod(isEnabled, null, [success, failure]);

         function isConnected(success, failure) {            
            window.bluetoothSerial.isEnabled(success, failure);
         }
      }
   }
})
.run(function($rootScope,$services)
{})

Re: Error with Phonegap Plugin

PostPosted: Thu Feb 06, 2020 11:50 am
by ROCLASI
francisco.garcia wrote:Now i get the following error.
Error while executing client side code. Please see browser console for more info. Error: ReferenceError: Bridge is not defined


Just by looking at your code and the error, it seems that the library that holds the Bridge.* code doesn't load.

Did you do what the error suggests? Do you get more info in the browser console? If so, you might want to post it here.

Re: Error with Phonegap Plugin

PostPosted: Thu Feb 06, 2020 1:38 pm
by francisco.garcia
Hi ROCLASI,
This is what i get from the browser console
Code: Select all
Error (follows below) in parsing/processing this message: 34#{"services":[{"call":"isEnabled","args":[{"script":"Uh3P9YzADSfXW4e2dMM4y/8rmVqYbpuCNWrkM0ji8TdOeG/hta/qpQ=="},{"script":"Uh3P9YzADSfXW4e2dMM4y/8rmVqYbpuCp1ZE8hNCDmBH7EnuYQLK8Q=="}],"name":"idbluetoothserialIdbluetoothserial"}],"smsgid":9}
(anonymous) @ angular.js:15567
handleMessage @ websocket.js:369
websocket.onmessage @ websocket.js:689
(anonymous) @ reconnecting-websocket.js:179
ws.onmessage @ reconnecting-websocket.js:280

Code: Select all
ReferenceError: Bridge is not defined
    at Object.isEnabled (idbluetoothserial.js:35)
    at handleMessage (websocket.js:291)
    at ReconnectingWebSocket.websocket.onmessage (websocket.js:689)
    at HTMLDivElement.<anonymous> (reconnecting-websocket.js:179)
    at WebSocket.ws.onmessage (reconnecting-websocket.js:280)

Re: Error with Phonegap Plugin

PostPosted: Tue Feb 11, 2020 1:16 pm
by francisco.garcia
Any ideas on this?