# Error with Phonegap Plugin

**URL:** <https://forum.servoy.com/t/error-with-phonegap-plugin/20182>\
**Category:** Questions\
**Created:** [February 5, 2020, 5:17pm UTC](https://forum.servoy.com/t/error-with-phonegap-plugin/20182 "2020-02-05T17:17:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![francisco.garcia](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/francisco.garcia/32/5081_2.png) [@francisco.garcia](https://forum.servoy.com/u/francisco.garcia)\
**Post date:** [February 5, 2020, 5:17pm UTC](https://forum.servoy.com/t/error-with-phonegap-plugin/20182/1 "2020-02-05T17:17:59Z")

</div>

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

```auto
<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

```auto
<?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" >

	<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

```auto
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)
{})

```

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [February 6, 2020, 9:50am UTC](https://forum.servoy.com/t/error-with-phonegap-plugin/20182/2 "2020-02-06T09:50:47Z")

</div>

> francisco.garcia:  
> 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.

---

<div class="post-metadata">

**Author:** ![francisco.garcia](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/francisco.garcia/32/5081_2.png) [@francisco.garcia](https://forum.servoy.com/u/francisco.garcia)\
**Post date:** [February 6, 2020, 11:38am UTC](https://forum.servoy.com/t/error-with-phonegap-plugin/20182/3 "2020-02-06T11:38:11Z")

</div>

Hi ROCLASI,  
This is what i get from the browser console

```auto
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

```

```auto
 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)

```

---

<div class="post-metadata">

**Author:** ![francisco.garcia](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/francisco.garcia/32/5081_2.png) [@francisco.garcia](https://forum.servoy.com/u/francisco.garcia)\
**Post date:** [February 11, 2020, 11:16am UTC](https://forum.servoy.com/t/error-with-phonegap-plugin/20182/4 "2020-02-11T11:16:52Z")

</div>

Any ideas on this?
