Ionic StatusBar undefined. Default is coming light - ionic-framework

I am trying to get the default StatusBar which is black, but it's coming light. When I try to set as black the error is Uncaught ReferenceError: StatusBar is not defined including the plugin on https://github.com/apache/cordova-plugin-statusbar.git.
I removed and added several times, but the StatusBar is still light.
cordova-plugin-console 1.0.2 "Console"
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-file 4.1.0 "File"
cordova-plugin-media 2.1.0 "Media"
cordova-plugin-splashscreen 3.1.0 "Splashscreen"
cordova-plugin-statusbar 2.1.0 "StatusBar"
cordova-plugin-vibration 2.1.0 "Vibration"
cordova-plugin-whitelist 1.2.1 "Whitelist"
ionic-plugin-keyboard 1.0.8 "Keyboard"
The code is:
console.log(StatusBar);
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}

You need to wait for the deviceready event to be able to use Cordova plugins.
The simplest way to do this would be to wrap your code in a ionic.Platform.ready() call, like this:
ionic.Platform.ready(function() {
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});

I faced exactly the same problem.
just delete the platform,
and delete all plugins.
clean your project
then add your plugins again,
then add the platform again.
compile and run.
ensure also that you delete manually the plugins folder from your projects after deleting you plugins using cordova plugin rm <PLUGIN NAME>.
Tell me if it worked with you. Happy Coding.

Related

Ionic 3 Native Plugin Social Sharing Error: Plugin not installed

I’m using an Ionic 3 app, trying to get social sharing working.
I followed the steps to install the Ionic Native Social Sharing plugin from: https://ionicframework.com/docs/v3/native/social-sharing/
Ran:
$ ionic cordova plugin add cordova-plugin-x-socialsharing
$ npm install --save #ionic-native/social-sharing#4
Imported the plugin (version 4.x.x) via my app module and added SocialSharing to the providers array.
Imported the plugin via my app.component using:
import { SocialSharing } from '#ionic-native/social-sharing';
Added to the constructor:
private socialSharing: SocialSharing
This share function, also in app.component is triggered via a button in the html (side menu):
async share() {
try {
// Pop the native social sharing sheet, allowing the user to choose how to share the app.
await this.socialSharing.share(this.shareMessage, this.shareSubject, this.shareFile, this.getShareUrl());
this.toast.show('Thanks for sharing!', 3000);
}
catch(err) {
console.error(err);
alert(err);
}
}
I’m using platforms: ios, android and browser.
When I call the method from a build on a real device I get the error:
"Plugin is not installed"
Tried:
Checking logs for installation errors. None seen.
Reinstalled plugin.
Checked plugin present using $ionic cordova plugin list. cordova-plugin-x-socialsharing 5.4.7 “SocialSharing” is present.
Removed and added all platforms again.
Wrapped the share method inside a platform.ready().
Nothing seems to be working. I cannot get the app to recognise the plugin is installed!
PLEASE HELP! :slight_smile: What can I try next?
Thanks
$ionic info:
Ionic:
Ionic CLI : 5.2.3 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.5
#ionic/app-scripts : 3.2.2
Cordova:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : android 8.0.0, browser 6.0.0, ios 5.0.1
Cordova Plugins : cordova-plugin-ionic 5.4.0, cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.5.1, (and 13 other plugins)
Utility:
cordova-res : 0.4.0 (update available: 0.6.0)
native-run : not installed
System:
ios-deploy : 1.9.4
ios-sim : 8.0.2
NodeJS : v11.2.0 (/usr/local/Cellar/node/11.2.0/bin/node)
npm : 6.9.2
OS : macOS Mojave
Xcode : Xcode 10.2 Build version 10E125
So according to your information your current installed plugin is version 5.4.7, to make plugins work with Ionic 3 you need to ensure you have installed 4.* version of the plugin.
Seems like you are using the right command for the install (adding #4 after the plugin install command).
Can you try uninstall the plugin and then attempt to reinstall and note which version its installing. You may have to try and install 4.* version:
npm install --save #ionic-native/social-sharing#4.12.0
I got an issue with cordova-plugin-x-socialsharing in Ionic3 and main issue was couldn't install cordova-plugin-x-socialsharing plugin properly(error: can't find plugin.xml for es6-promise-plugin).
Steps to fix:
Installed es6-promise-plugin : ionic cordova plugin add https://github.com/vstirbu/PromisesPlugin
Installed cordova-plugin-x-socialsharing : ionic cordova plugin add cordova-plugin-x-socialsharing
npm install --save #ionic-native/social-sharing#4

Property 'iOSExternalAccessory' does not exist on type 'CordovaPlugins'

I have created a new Ionic 4 menu template app and then I have installed the following plugin with deps. using the CLI command
ionic cordova add https://github.com/stevef51/cordova-ios-external-accessories
However when I try ionic cordova prepare ios, I am presented the following error.
ERROR in src/app/home/home.page.ts:25:39 - error TS2339: Property 'iOSExternalAccessory' does not exist on type 'CordovaPlugins'.
25 var pluginAPI = cordova.plugins.iOSExternalAccessory;
~~~~~~~~~~~~~~~~~~~~
[ERROR] An error occurred while running subprocess ng.
When I run the command
ionic cordova plugin list, I can see it installed
com.virtualmgr.iOSExternalAccessory 1.0.0 "iOSExternalAccessory"
cordova-plugin-ble-central 1.2.2 "BLE"
cordova-plugin-bluetooth-serial 0.4.7 "Bluetooth Serial"
cordova-plugin-bluetoothle 4.5.5 "Bluetooth LE"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.1.1 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
The code is dead simple: a click event, if I take it out the BLE code works just fine, however I am forced to use this plugin as the handheld scanner I am using does not support BLE as it does not show up in the list of accessories when I scan for BLE devices.
scanForDevices(){
var pluginAPI = cordova.plugins.iOSExternalAccessory;
this.ble.scan([], 5).subscribe(device => {
console.log(JSON.stringify(device));
});
}
I have made contact with the developer of the plugin, he has no Ionic experience, unfortunately.
Any and all advice would be appreciated.
I have worked it out.
I was missing the declare let cordova: any; at the top of my file.

$cordovaLocalNotification - TypeError - cannot read property 'local' of undefined

I am running into an issue while utilizing $cordovaLocalNotification within my ionic app where the below code yields an error message TypeError: Cannot read property 'local' of undefined
try{
if($scope.active.checked){
$cordovaLocalNotification.schedule({
id: 1,
title: 'Notification',
text: 'You are currently publishing your location.'
}).then(function(result){
AlertService.notify('Success', 'Successfully notified customer')
}, function(err){
AlertService.notify('Error', 'Failed to notify customer')
});
} else {
$cordovaLocalNotification.cancel(1);
}
}catch(err){
AlertService.notify('Issue', err)
}
So, after reading a few responses around needing to verify ionicPlatform.ready() and ensuring the plugin is installed properly (and verifying those aren't the issues), I am at a lost. I believe this issue is caused by cordova.plugins.notification not being defined, but I'm not sure why this plugin isn't being loaded properly.
From Ionic, I have the following plugins:
cordova-plugin-app-event 1.2.0 "Application Events"
cordova-plugin-camera 2.3.0 "Camera"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-console 1.0.4 "Console"
cordova-plugin-device 1.1.3 "Device"
cordova-plugin-geolocation 2.4.0 "Geolocation"
cordova-plugin-splashscreen 4.0.0 "Splashscreen"
cordova-plugin-statusbar 2.2.0 "StatusBar"
cordova-plugin-whitelist 1.3.0 "Whitelist"
de.appplant.cordova.plugin.local-notification 0.8.4 "LocalNotification"
ionic-plugin-keyboard 2.2.1 "Keyboard"
So far, for my own sanity, I have:
Installed the plugin manually using cordova plugin add de.appplant.cordova.plugin.local-notification
Removed platform, remove plugins, then execute ionic state restore
Also, a good item to note is I am utilizing ionicView to test. All/any help would be appreciated.
It turns out that mocking this on the emulator or physical device works fine. So it was a good learning experience that not all cordova plugins operate in ionicView

I get a Could not find InAppBrowser plugin in ionic ios app

I have created a simple Ionic app in which I want to integrate Facebook login, however when I try to sign in, I get the message Could not find InAppBrowser plugin.
After searching a bit on the web I found out that it might be because of the plugin name which has changed overtime from cordova-plugin-inappbrowser to org.apache.cordova.inappbrowser.
The suggested solution were to edit the ng-cordova.js file to reference the plugin name I was using, but when I went to edit it, it was already referencing both plugin names inside that function :
isInAppBrowserInstalled: function(cordovaMetadata) {
var inAppBrowserNames = ["cordova-plugin-inappbrowser", "org.apache.cordova.inappbrowser"];
return inAppBrowserNames.some(function(name) {
return cordovaMetadata.hasOwnProperty(name);
});
},
I tried to alert(JSON.stringify(cordovaMetadata)); to see what was going on, but it returned an empty object like {}.
Also, if I do cordova plugin ls, here is what I get:
cordova-plugin-console 1.0.1 "Console"
cordova-plugin-device 1.0.1 "Device"
cordova-plugin-file 3.0.0 "File"
cordova-plugin-inappbrowser 1.0.1 "InAppBrowser"
cordova-plugin-media 1.0.1 "Media"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-statusbar 1.0.1 "StatusBar"
cordova-plugin-whitelist 1.0.0 "Whitelist"
ionic-plugin-keyboard 1.0.7 "Keyboard"
i had the same problem, and instead of using:
"cordova plugin add org.apache.cordova.inappbrowser"
I used:
"cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git"
And it works, i follow the instructions of this link:
https://github.com/nraboy/ng-cordova-oauth/issues/57
Good luck

Can't run Ionic on Android: class not found exception IonicKeyboard

After building and running android app it closes.
Viewing Eclipse logcat it shows a class not found exception com.ionic.keyboard.IonicKeyboard
I'm new with Ionic and I don't know how to make it work. Thanks in advance
I had the same problems.
In my case the plugin was already installed, so I had to remove and add it again:
Try this in your app-folder:
cordova plugin remove com.ionic.keyboard
and
cordova plugin add com.ionic.keyboard
npm changed plugin names. Now it should be
cordova plugin add ionic-plugin-keyboard
Try this in your app-folder:
cordova plugin remove ionic-plugin-keyboard
and
cordova plugin add ionic-plugin-keyboard
Seems that plugin not installed?
Try in cmd:
cordova plugin add com.ionic.keyboard