Ionic/Cordova plugins doesn't work iOS - ios

I'm developing a mobile app both for iOS and Android, I didn't have any issues on android. But in iOS I encountered a problem when using plugins. Plugins I used were cordova-file-transfer and social sharing by EddyVerbruggen. Both plugins worked perfectly when I created my android app, but both got an issue when I did it in iOS. Both plugin only works after I restart the app. Why is that? I tried surrounding the code with $ionicPlatform.ready and device.ready but didn't help. What am I missing?
Here's a sample sequence code:
$scope.myButton = function(){
//I also tried surrounding this with
//document.addEventListener("deviceready", myfunction, false)
$ionicPlatform.ready(function(){
//mycode here that uses the plugin ex. ($cordovaFileTransfer.download)
});
}

Related

cordova-plugin-dbmeter crashes on iOS, works fine on Android

I’m implementing the Cordova plugin cordova-plugin-dbmeter through the Ionic Native wrapper (#ionic-native/db-meter). It works fine on Android, but on iOS, the plugin crashed when initialized. It builds fine in Xcode, though. And all other plugins (Capacitor, Ionic Native, Cordova) works just fine.
The error message I get is:
CordovaPlugins/DBMeter.swift:5: Fatal error: Use of unimplemented
initializer ‘init(webViewEngine:)’ for class ‘CordovaPlugins.DBMeter’
And here it crashes:
I’ve tried using the plugin without the wrapper, but no success. Using plain Cordova, the plugin requires cordova-plugin-add-swift-support, but Capacitor doesn’t support it and should provide the necessary Swift support anyway.
Anyone has got this to work, or have any ideas? Getting lots of gray hair over this.

ADAL for Cordova - Assistance Getting Started

Hello: I'm trying to get started with the ADAL plug-in for Cordova. Having used the native libraries a few times, I thought this would be pretty straightforward but I ran into a bit of an issue.
First of all my environment is VS2017, and the plugin is ADAL for Cordova 0.10.1.
I've created what I believe is the most simplistic example of a connection, using my own client application specifics and the ones provided in their sample online (which is) included below. My authentication looks like:
function authenticate(authCompletedCallback, errorCallback) {
var authority = "https://login.microsoftonline.com/common",
redirectUri = "http://localhost:4400",
resourceUri = "https://graph.windows.net",
clientId = "a5d92493-ae5a-4a9f-bcbf-9f1d354067d3";
var authContext = new Microsoft.ADAL.AuthenticationContext(authority);
authContext.acquireTokenAsync(resourceUri, clientId, redirectUri).then(authCompletedCallback, errorCallback);
This is then called in onDeviceReady();
acquireTokenAsync is called but doesn't appear to return either success or failure and a quick Fiddler trace doesn't appear to show the call which makes me wonder if it is not a configuration issue with Cordova to begin with.
I have commented out the Content-Security-Policy metatag with similar results.
Thank you in advance for any guidance!
Edit
Okay, perhaps this is helpful. I noticed that on the Cordova Plugin Simulation tab (I am trying to run this in the simulator in Chrome). I am seeing a dialog box with error:
There is no handler for the following exec call:
ADALProxy.acquireTokenAsync(...
Also, seems to work on a connected Android Device, just not in the local Simulator
The plug-in for Cordova doesn't support to run on the browser platform. When we developer an Cordova app and want to test on the browser platform, we have to ensure that the app depends on support the browser platform.
For the ADAL plug-in for Cordova support the platform:
Android (OS 4.0.3 and higher)
iOS Windows (Windows 8.0, Windows 8.1,
Windows 10 and Windows Phone 8.1)
And for other kinds of plug-in you can check it via you the Cordova plug-in.

Camera.DestinationType.FILE_URI is not working on IOS only

we have migrated a worklight 6.1 application t IBM mobilefirst 7.0 platform and all the functionalities working as expected on the android environment, but in ios we are facing an issue: there is a function called "quick receipt". on click on a button the device camera opens and a photo is taken. The problem is that the photo is not displaying - it returns complete blank page this issue on ios device only but not on Android device.
Camera.DestinationType.FILE_URI is not working on IOS.
for security reason we wont share the code. here is similar prototype code.
html
<div><img alt="QuickReceipts" src="resources/img/camera.png" onclick="imgCapture();"</div>
JavaScript
imgCapture: function (){
navigator.camera.getPicture(this.onSuccess, this.onFail,{quality:80,destinationType:Camera.DestinationType.FILE_URI, targetWidth:600,targetHeight:1050}
},
onSuccess:function(imgData)
{
// applying the css and displaying the img
$("#imgReceipt").attr("src","data:image/jpeg;base64," +imgData);
$("#imgReceipt").css("display", "block");
}
onFail:function(imgData){
// failure msg
}
One suggestion is to attempt to code change as mentioned by Nazmul: http://www.telerik.com/forums/ios-cordova-3-5-0-camera-getpicture-targetwidth-issue.
Another suggestion is to upgrade to the latest 7.1 iFix from IBM Fix Central which contains several Cordova corrections and may address your issue.
If your issue is not resolved still, I suggest to open an IBM PMR (support ticket).

console.log not working in phonegap when built for ios (plugin is installed)

I'm pulling my hair out on this one. I'm using phonegap 3.4 to build an iOS app. When I build the project and run in the simulator, I want to view the output of console.log in the xcode debug window, but it's not working. I've installed the org.apache.cordova.console plugin, but no luck. I see some normal debug output like "Resetting plugins due to page load" but none of my console.logs appear. Any ideas?
And this did not solve my issue: console.log is not working in iOS Phonegap App even after adding the console plugin
try alert();
it is basically the same as console.log();
but you need to install different plugins: org.apache.cordova.dialogs
i dont have iphone nor mac so i can't guarantee it will work on them. But in one android device that i tried, when the console.log() fails. Alert() succeeds.
There are 2 types of alert:
alert('text'); //this is actually javascript
navigator.notification.alert(message, alertCallback, [title], [buttonName]) //this is phonegap function
In my case. i have only need to use the first one.
further documentation on the second alert function is below:
https://cordova.apache.org/docs/en/3.0.0/cordova_notification_notification.md.html#notification.alert
i hope it will work on xcode too.
Make sure you install the console plugin. While Android is able to do this out of the box, logging to console is otherwise not supported on iOS:
https://github.com/apache/cordova-plugin-console/blob/master/doc/index.md
The solution is: call logger.__onDeviceReady function from your deviceready listener function:
function onDeviceReady() {
if (window.cordova.logger) {
window.cordova.logger.__onDeviceReady();
}
}
document.addEventListener('deviceready', onDeviceReady, false);
Try to use "document.write" instead.

PhoneGap Android Plugin: ContactView error

I'm using PhoneGap + jQuery Mobile for a new mobile app.
This plugin is used to call native contact view of Android so you don't have to inject contacts in HTML.
https://github.com/phonegap/phonegap-plugins/tree/master/Android/ContactView
I've followed the instructions properly but it doesn't work for me, whenever I try to run (after all the initialization routine) this JS on Android:
window.plugins.contactView.show(
function(contact) {
console.log(contact);
},
function(fail) {
console.log(fail);
}
);
It shows this error:
Error: Status=2 Message=Class not found
Can anyone help?
Note: I haven't used any PhoneGap plugin before.
http://simonmacdonald.blogspot.com/2011/05/installing-childbrowser-plugin-on.html
The issue has been described here in details.

Resources