exec() call to unknown plugin: StatusBarNotification - android

I don't know why the plugin manager throw exec() call to unknown plugin: StatusBarNotification, I downloaded a example and tried to make it equal, but I couldn't.
I am using phonegap 3.5
config.xml
<plugin name="StatusBarNotification" value="com.phonegap.plugins.statusBarNotification.StatusBarNotification"/>
index.html
<body>
<div class="app">
<h1>PhoneGap</h1>
<button onclick="sendNotification()"> Mensaje</button>
</div>
</div>
</div>
<script type="text/javascript" src="js/statusbarnotification.js"></script>
<script type="text/javascript" charset="utf-8">
function sendNotification() {
window.plugins.statusBarNotification.notify("Sample Notification", "mensajito");
}
</script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>

It looks like the plugin you are using is not for Cordova/PhoneGap >= version 3.0.
Since 3.0, everything should be done via the CLI, including installing plugins: https://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html
You then don't include references to any plugin javascript, as Cordova takes care of this.
You can search for compatible plugins on either of these 2 sites:
http://plugreg.com
http://plugins.cordova.io
Hopefully this helps.

Related

window.plugins object is undefined in cordova

I'm making an app in cordova. I've installed some plugins, but problem is that I cannot use those plugins as when I try to call them like window.plugins.googleplus.login then it says property 'plugins' does not exists on window. So I searched from solution and they said use window['plugins'] I tried that too, but now it says undefined.
I tried cordova plugins ls and it lists all my plugins. Also checked available plugins in android.json, all plugins are there. Can anyone help me why it is undefined? My index.html looks like below.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Scrmbl</title>
<base href="./">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<base href="./">
<script type=”text/javascript” src="cordova.js"></script>
</head>
<body>
<app-root>
<center>
<div style="margin-top: 200px;">
<img src="./assets_v2/images/icon.png" alt="" >
<br><br>
<img src="./assets_v2/images/preloader.gif" alt="">
</div>
</center>
</app-root>
</body>
</html>
Any help will be highly appreciated.
cordova --version
8.0.0
I think you are calling it without deviceready. None of the googleplus methods should be called before deviceready has fired. The plugin should be called when everything's ready for the plugin to be called.
Example:
document.addEventListener('deviceready', deviceReady, false); function deviceReady() {
console.log('Device is ready!'); window.plugins.googleplus.trySilentLogin(...); }
Reference visit here

Cordova deviceReady not called on Android platform

I am trying to build a simple cordova app on iOS and Android. It worked fine on iOS. However it fails to execute on android. I am using Android Studio.
The html file still runs in android, but the addEventListener for deviceReady is not working.
This piece of code works fine in iOS but not in android:
<p id="ready" style="text-align: center">deviceready not called yet</p>
<script type="text/javascript" src="cordova-2.4.0.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready", function() {
console.log("cordova ready");
var readyElement = document.getElementById("ready");
readyElement.innerHTML = "deviceready called but not finished";
readyElement.innerHTML = "Ready";
console.log('Ready');
}, false);
</script>
I have included the both cordova-2.4.0.js and cordova.js in the project folder, but I have no idea why it doesnt connect properly.
After the page loads, the label 'device ready not called yet should be changed to device ready' , but it doesnt change in android. Can anyone suggest me the right way to do it ?
Note: 'cordova.js' is generated by the cordova in android , and 'cordova-2.4.0.js' is the one generated in iOS.
Even though I copied the iOS cordova-2.4.0.js file, it didnt worked.
Looks like I have to include only one cordova.js file generated by the cordova .
I removed the line:
<script type="text/javascript" src="cordova-2.4.0.js"></script>
and I used only:
<script type="text/javascript" src="cordova.js"></script>
and it worked.

Try to open link in new project Phonegap

What I do wrong when I try to make an app with PhoneGap Build?
I want to make an app which open external link
I make in CMD phonegap project
phonegap create my-app
Here my config.xml and GAP plugin
<gap:plugin name="org.apache.cordova.inappbrowser" />
index.html BODY
<div class="app">
<h1>PhoneGap</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</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();
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.open = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
}
</script>
Then I make a ZIP and load to PhoneGap Build
And make an APK...
But my APP doesn't open link.
What I do wrong?
You have a onDeviceReady function in your app object in your index.js. Try adding window.open there like this:
onDeviceReady: function() {
app.receivedEvent('deviceready');
window.open = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
},
Maybe you didn't install the plugin by running this command in the cmd:
phonegap plugin add cordova-plugin-inappbrowser
EDIT:
When your device is plugged in you can go to the link below and look at the console for errors:
chrome://inspect

PhoneGap Build facebookconnect plugin problems

i'm new with PhoneGap build and i'm tryng to write a simple app with a button for facebook login. In PhoneGap build documentation i found is very simple to add this plugin
index.html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha256.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64-min.js"></script>
<script src="js/facebookConnectPlugin.js"></script>
<script src="js/jq.js"></script>
</head>
<body>
<div data-role="page" id="contenuto">
<a href="index.html" data-role="button" class='bt_loginProprietario'>Login</a>
<a href="index.html" data-role="button" class='bt_loginFacebook'>Login con facebook</a>
</div>
</body>
</html>
jq.js
function loginFacebook(){
facebookConnectPlugin.login( ["email"],
function (response) { alert(JSON.stringify(response)) },
function (response) { alert(JSON.stringify(response)) };
};
$(document).ready(function(){
$('#contenuto').on('click','.bt_loginFacebook',function(){
loginFacebook();
});
});
in PG build i see the plugin correctly loaded but when i try to execute the app on my android phone nothing happens when i click on button. i tried to execute in my browser and i receive the error "cordova is not defined
thx for the help this is my first post, i don't understand what is wrong
update
with your suggestion my jq.js now has this code:
document.addEventListener("deviceready", function(){
$('#contenuto').on('click','.bt_loginFacebook',function(){
loginFacebook();
});
});
but when i press the button nothing happens, i saw an error in my chrome console that says cordova is not defined
help pls
This is very common for person new to cordova/phonegap.
You are using a facebook plugin for phonegap. Phonegap REQUIRES that you wait until the deviceready event fires before you access any phonegap or 3rd-party plugin services. This blog post explains in more detail.
FYI – Cordova events must be run after deviceReady
http://www.raymondcamden.com/2015/07/15/fyi-cordova-events-must-be-run-after-deviceready

Close android hybrid app that was builded by IntelXDK android build

I'm creating java script hybrid app with IntelXDK android build for android platform.
I'm unable to exit from my app using following code:
<html>
<head>
<title></title>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript"">
function onLoad()
{
document.addEventListener("deviceready", onDeviceReady, true);
}
function exitFromApp()
{
navigator.app.exitApp();
}
</script>
</head>
<body onload="onLoad();">
<button name="buttonClick" onclick="exitFromApp()">Click Me!</button>
</body>
</html>
The same code works well with IntelXDK crosswalk build.
How to close an app using android build?
I checked and it does not work in the android build. There will be an update late March that updates the android build to a newer cordova. I verified that it works here. Maybe you can continue to use crosswalk build until then?

Categories

Resources