Ionic camera plugin getPicture ignored - ionic-framework

This is freaking me. I have a simple app where you press a button and it take a picture, then the user can do other stuff but the problem is that sometime the getPicture function is ignored and camera never shows, here goes some info and simple code:
$ ionic info
Your system information:
Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
ios-deploy version: 1.9.1
ios-sim version: 5.0.13
OS: macOS Sierra
Node Version: v6.10.2
Xcode version: Xcode 8.3.2 Build version 8E2002
Installed platforms:
android 6.0.0
ios 4.3.1
plugins installed
$ ionic plugin ls
WARN: ionic.project has been renamed to ionic.config.json, please rename it.
com.googlemaps.ios 2.1.1 "Google Maps SDK for iOS"
cordova-plugin-camera 2.4.0 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.3 "Console"
cordova-plugin-device 1.1.2 "Device"
cordova-plugin-file 4.3.1 "File"
cordova-plugin-file-transfer 1.6.1 "File Transfer"
cordova-plugin-geolocation 2.4.2 "Geolocation"
cordova-plugin-googlemaps 1.4.0 "phonegap-googlemaps-plugin"
cordova-plugin-screen-orientation 1.4.2 "Screen Orientation"
cordova-plugin-splashscreen 3.2.2 "Splashscreen"
cordova-plugin-statusbar 2.1.3 "StatusBar"
cordova-plugin-whitelist 1.2.2 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
Then we have a HTML with this button
<button class="button button-full button-positive" ng-click="take_picture()">Take photo</button>
And the function into the controller
$scope.take_picture = function()
{
screen.lockOrientation('portrait');
var options = {
quality: 25,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
encodingType: Camera.EncodingType.JPEG,
saveToPhotoAlbum: false,
correctOrientation: true,
allowEdit: false,
targetHeight: 200,
targetwidth: 200
};
$cordovaCamera.getPicture(options).then(function(imageURI) {
$scope.image_uri = imageURI;
$scope.marcar_gps();
$cordovaCamera.cleanup();
}, function(err) {
console.log('error ',err);
$cordovaCamera.cleanup();
$ionicLoading.hide();
});
};
Hope someone can help.
Best!
EDIT
When camera is skipped on xCode console I get this:
Warning: Attempt to present on which is already presenting

Avoid using DATA_URL destinationType and replace it with FILE_URI as it may consume so much memory on the old phones. When you're using FILE_URI as destinationType, you can use cordova file plugin to transfer image to the external/internal storage, then you can call the image src link to your local device url.
EDIT
camera plugin and orientation plugin wasn't up to date. So need it to update from versions 2.4.0 "Camera" and 1.4.2 "Screen Orientation" to 2.4.1 "Camera" and 2.0.1 "Screen Orientation"

Related

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.

net::ERR_CONNECTION_REFUSED (WEB PAGE NOT AVAILABLE) IONIC V4 APP

i am added kapsel plugins to my ionic app.and generated build and installed apk in app.i am getting this error
web page at http://localhost/smp/ui/iab.html could not be loaded because:
net::ERR_CONNECTION_REFUSED
ionic cordova plugin
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
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"
kapsel-plugin-authproxy 4.2.8 "AuthProxy"
kapsel-plugin-corelibs 4.2.8 "CoreLibs"
kapsel-plugin-i18n 4.2.8 "i18n"
kapsel-plugin-inappbrowser 4.2.8 "InAppBrowser"
kapsel-plugin-logon 4.2.8 "Logon"
kapsel-plugin-ui5 4.2.8 "ui5"
Please find attachment
https://odsol-my.sharepoint.com/:i:/g/personal/gsreddy_ondevice_co_uk/EVT4LR3rt55Jk3IyCiLNHO8Bkd8rxYZnFAdzAw2wbcaolA?e=HQgvC8
Normally I would expect to see a port number next to the localhost url like the default 8100:
http://localhost:8100/
Have you hardcoded the wrong url somewhere?

Cordova app on iOS 9x not working

I am testing my cordova app via Xcode simulator on multiple phone types running various versions of 9x through 11x. The app installs and works as intended on all devices running 10x and 11x but is not working on devices running 9x (specifically 9.3). On 9x devices, my app splash screen shows up and then the screen goes white.
In Xcode console I get zero errors or warnings - from a console perspective it just looks like a successful install. However, when trying to access Safari -> Develop -> Simulator - the app is not appearing as running so I can't view anything in Safari. I have no idea what to look for or what could be causing this. Any ideas or thoughts as to where/what to look for? This is consistently happening on any simulator device running 9.3 (5s, 6, 6 plus, 6s, 6s plus)
My app is running:
Cordova 4.5.0
Ionic: 1.7.14
cocoapods 1.3.1
And my installed plugins:
cl.rmd.cordova.dialoggps 0.0.2 "DialogGPS"
com.lampa.startapp 0.1.4 "startApp"
com.ludei.webview.plus 2.3.0 "Webview+"
com.peerio.cordova.plugin.carrier 1.0.1 "Carrier"
com.phonegap.plugins.nativesettingsopener 1.0.1 "Native settings"
com.vliesaputra.deviceinformation 1.0.1 "DeviceInformation"
cordova-instagram-plugin 0.5.5 "Instagram"
cordova-plugin-admobpro 2.29.22 "AdMob Plugin Pro"
cordova-plugin-appavailability 0.4.2 "AppAvailability"
cordova-plugin-appinfo 2.1.2 "AppInfo Plugin"
cordova-plugin-apprate 1.3.0 "AppRate"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-device-motion 1.2.5 "Device Motion"
cordova-plugin-device-orientation 1.0.7 "Device Orientation"
cordova-plugin-dialogs 1.3.3 "Notification"
cordova-plugin-email 1.2.6 "EmailComposer"
cordova-plugin-extension 1.5.2 "Cordova Plugin Extension"
cordova-plugin-fastrde-checkgps 1.0.0 "checkGPS"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-firebase 0.1.24 "Google Firebase Plugin"
cordova-plugin-geolocation 1.0.1 "Geolocation"
cordova-plugin-globalization 1.0.7 "Globalization"
cordova-plugin-inappbrowser 1.7.1 "InAppBrowser"
cordova-plugin-network-information 1.3.3 "Network Information"
cordova-plugin-queries-schemes 0.1.1 "App Queries Strings"
cordova-plugin-request-location-accuracy 2.2.2 "Request Location Accuracy"
cordova-plugin-sim 1.3.3 "SIM"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-vibration 2.1.5 "Vibration"
cordova-plugin-whitelist 1.3.1 "Whitelist"
cordova-sms-plugin 0.1.11 "Cordova SMS Plugin"
cordova-universal-clipboard 0.1.0 "Clipboard"
cordova.plugins.diagnostic 3.7.1 "Diagnostic"
ionic-plugin-keyboard 2.2.1 "Keyboard"
On a side note, it would be easy to just ignore 9x and keep my app at 10x/11x, however, nearly 10% of the iOS install base is still running iOS 9x - thats a pretty significant user base to ignore.

Cannot debug ionic app

I have an ionic v1 app.
It uses following plugins:
cordova-plugin-console 1.0.4 "Console"
cordova-plugin-device 1.1.3 "Device"
cordova-plugin-firebase 0.1.19 "Google Firebase Plugin"
cordova-plugin-globalization 1.0.6-dev "Globalization"
cordova-plugin-inappbrowser 1.7.0 "InAppBrowser"
cordova-plugin-splashscreen 4.0.0 "Splashscreen"
cordova-plugin-statusbar 2.2.0 "StatusBar"
cordova-plugin-transport-security 0.1.2 "App Transport Security"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-facebook-plugin 0.12.0 "Facebook Connect"
When I try to run something like cordova run browser I have following output
Linting www/js/views.js
File www/js/views.js has no errors.
-----------------------------------------
Error: Cannot read property 'variables' of undefined
How can I fix this?

$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