ios phonegap plugin from a static library - ios

I have a iOS custom phonegap plugin packaged as a iOS static library. When I try to include this library in any other phonegap project, I am getting the PHONEGAP error on my console:
ERROR: Plugin 'Device' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml
As suggested, I am suspecting the config.xml is to be blamed. I wanted to know how/what is the right way of referencing an iOS plugin class (which is inside a static library) in the config.xml
Current implementation:
eg:
<feature name="CustomPlugin">
<param name="ios-package" value="CustomPlugin"/>
</feature>
where the static library included is libCustomPlugin.a(containing object ~ CustomPlugin.o) and the header is CustomPlugin.h
Thanks in advance

For me on PhoneGap 2.7.0 I have a config.xml with something like:
<plugins>
<plugin name="Accelerometer" value="CDVAccelerometer"/>
<plugin name="Battery" value="CDVBattery"/>
<plugin name="Camera" value="CDVCamera"/>
<plugin name="Capture" value="CDVCapture"/>
<plugin name="Compass" value="CDVLocation"/>
<plugin name="Contacts" value="CDVContacts"/>
<plugin name="Debug Console" value="CDVDebugConsole"/>
<plugin name="Device" value="CDVDevice"/>
<plugin name="Echo" value="CDVEcho"/>
<plugin name="File" value="CDVFile"/>
<plugin name="FileTransfer" value="CDVFileTransfer"/>
<plugin name="Geolocation" value="CDVLocation"/>
<plugin name="Logger" value="CDVLogger"/>
<plugin name="Media" value="CDVSound"/>
<plugin name="NetworkStatus" value="CDVConnection"/>
<plugin name="Notification" value="CDVNotification"/>
<plugin name="SplashScreen" value="CDVSplashScreen"/>
<plugin name="InAppBrowser" value="CDVInAppBrowser"/>
</plugins>
Your project is complaining because the "Device" plugin can't be found - it is a standard PhoneGap (Cordova) plugin which will be required by your project. So not connected to any custom plugins.

Related

iOS Ajax error for local files in www folder, using Cordova ios 6.2.0 + Cordova 11

I am trying to create my first ios cordova app via Volt Builder online build service (successor to Phonegap Build) which uses cordova 11 + cordova-ios 6.2.0.
When I try to load a local file from the www folder with an ajax call I get an error on the app. The code works fine in Chrome desktop and almost identical code works in several android apps, so I believe the problem lies in config.xml and not the code itself.
whatever code is in comments, I have tried some combination of it without success.
(I am also aware that "async: false" doesn't work on iOS)
index.html
//$.support.cors = true;
$.ajax({
//async: false,
type: "GET",
url: "lang/en/strings.xml",
dataType: "text",
//cache: false,
//headers: { "cache-control": "no-cache" },
success: function(data) { /*do stuff here*/ },
error: function(e){ alert(e.statusText); }
});
config.xml (the relevant stuff only)
<access origin="*" />
<allow-navigation href="*" />
<allow-intent href="http://*/*" />
<plugin name="cordova-plugin-network-information" />
<plugin name="cordova-plugin-inappbrowser" />
<plugin name="cordova-plugin-browser" source="npm"/>
<plugin name="cordova-plugin-dialogs" />
<plugin name="cordova-plugin-device" />
<plugin name="cordova-plugin-file" />
<plugin name="cordova-plugin-filepath" source="npm"/>
<platform name="ios">
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
<preference name="WKWebViewOnly" value="true" />
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<!--<plugin name="#globules-io/cordova-plugin-ios-xhr" source="npm" version="1.0.3" />-->
<plugin name="cordova-plugin-wkwebview-engine" source="npm"/>
<plugin name="cordova-plugin-wkwebviewxhrfix" source="npm" />
<!--<plugin name="cordova-plugin-wkwebview-file-xhr" source="npm"/>-->
<!--<plugin name="#ahovakimyan/cordova-plugin-wkwebviewxhrfix" source="npm" />-->
</platform>
I have tried so many combinations of the above plugins that I have lost count, but all I get on the app is the 'error' alert.
I am aware of the following similar questions, but couldn't get it to work for me
Local (!) AJAX-Requests fail without error message in cordova-based app only in iOS
Why is jQuery Ajax not working in Cordova iOS app
In-app AJAX not working in iOS with Cordova 10
As I found out the hard way, you cannot define a plugin inside the <platform name="ios">, but have to do so globally.
Just the <plugin name="cordova-plugin-wkwebview-file-xhr" source="npm" version="3.0.0" /> (in the right place..) get's the job done.
<!-- more plugins/etc here-->
<plugin name="cordova-plugin-wkwebview-file-xhr" source="npm" version="3.0.0" />
<platform name="ios">
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
<preference name="WKWebViewOnly" value="true" />
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<!-- more stuff here -->
</platform>

Phonegap Build: cordova-plugin-contacts not loading

I am facing issues with my contacts plugin for last few days. While building application using PGB the contacts plugin is getting listed under plugin tab. But, while doing chrome inspect for my App, it is not getting loaded under android_assets/www/plugins folder. Due to which while trying to create object ContactFindOptions() under deviceready() ,I am facing Uncaught ReferenceError. Can someone please help. I have tested this on Android 5.1.1 and 6.0.1
Below are the screenshots.
PGB Plugins tab
Chrome Inspect Error and folder structure
config.xml
<!-- Core plugins -->
<plugin name="cordova-plugin-contacts" source="npm" />
<plugin name="cordova-plugin-calendar" source="npm" />
<plugin name="cordova-plugin-device" source="npm" />
<plugin name="cordova-plugin-globalization" source="npm" />
<plugin name="cordova-plugin-dialogs" source="npm" />
<plugin name="phonegap-plugin-push" spec="1.4.5" source="npm">
<param name="SENDER_ID" value=“##########” />
</plugin>
Got the solution.
The error is shown in the PGB log. Here, the latest version of cordova-plugin-contacts (3.0.1) is not compatible with PGB version (cli-6.5.0 Android 6.1.2), so need to downgrade the plugin.
spec="2.3.1" of cordova-plugin-contacts is compatible with cli-6.5.o of PGB.

Ionic/Cordova not using camera but apple requires permission

I am trying to upload a new version of my app, to App Store, but it was rejected because:
This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.
But my app do not need to access the camera. I already looked into plugins list (ionic plugin list) but there is no plugin for camera access.
This is part of my config.xml
<preference name="loadUrlTimeoutValue" value="3600000"/>
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="android-minSdkVersion" value="15"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="4000"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="orientation" value="portrait"/>
<preference name="KeyboardDisplayRequiresUserAction" value="false"/>
<preference name="exit-on-suspend" value="false"/>
<feature name="Keyboard">
<param name="ios-package" onload="true" value="IonicKeyboard"/>
</feature>
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar"/>
</feature>
<plugin name="cordova-sqlite-storage" spec="~0.7.14"/>
<plugin name="cordova-plugin-app-version" spec="~0.1.8"/>
<plugin name="cordova-plugin-network-information" spec="~1.2.0"/>
<plugin name="cordova-plugin-insomnia" spec="https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin.git"/>
<plugin name="com.testfairy.cordova-plugin" spec="https://github.com/testfairy/testfairy-cordova-plugin"/>
<plugin name="cordova-plugin-datepicker" spec="https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git"/>
<plugin name="onesignal-cordova-plugin" spec="~1.12.5"/>
<plugin name="de.appplant.cordova.plugin.local-notification" spec="https://github.com/katzer/cordova-plugin-local-notifications.git"/>
<plugin name="cordova-plugin-background-mode" spec="https://github.com/katzer/cordova-plugin-background-mode.git"/>
Anyone could help ?
You may have a plugin that has camera functionality that you are not using, but it is still part of the plugin. You also may have a plugin that has been installed previously but is not in your config.xml file. You can try the following:
Reset State
You can run ionic state restore to have Ionic restore the app to the saved parameters. This will re-install the plugins added via the CLI with the --save tag or ones you have manually added to the package.json file. This may clear up some residual code issues.
Add Description
You can just add the tag that Apple wants to see. You can add the tag using cordova-custom-config to edit your -Info.plist via your config.xml file. You should be able to add the following to config.xml to satisfy Apple:
<config-file platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription">
<string>Because racecar</string>
</config-file>

ionic cant get network connection consistently - when building for ios/android platform

I just cant consistently get a network connection for my ionic app on my ios device. It works sometimes with the reset, remove&add platforms but recently it just doesnt work. Im trying it over 10 times already. Its crazy.
How do i get network working consistently on ionic ? (cordova-plugin-network-information)
Im using ionic version 1.7.14
I'ved tried several ways like
ionic state reset
or
ionic platform remove ios
ionic platform add ios
I'ved got this error:
Error: undefined is not an object (evaluating 'navigator.connection.type')
in my config.xml, here are my plugins.
<plugin name="cordova-plugin-device" spec="~1.1.1" />
<plugin name="cordova-plugin-network-information" spec="~1.2.0" />
<plugin name="cordova-plugin-image-picker" spec="https://github.com/wymsee/cordova-imagePicker.git" />
<plugin name="cordova-plugin-whitelist" spec="~1.2.1" />
<plugin name="cordova-plugin-console" spec="~1.0.2" />
<plugin name="cordova-plugin-file-transfer" spec="~1.5.0" />
<plugin name="com.raananw.imageResizer" spec="https://github.com/RaananW/PhoneGap-Image-Resizer" />
<plugin name="cordova-plugin-inappbrowser" spec="~1.2.0" />
<plugin name="ionic-plugin-keyboard" spec="~2.0.1" />
<plugin name="cordova-plugin-splashscreen" spec="~3.1.0" />
<plugin name="cordova-plugin-camera" spec="~2.1.1" />
<plugin name="cordova-plugin-actionsheet" spec="https://github.com/EddyVerbruggen/cordova-plugin-actionsheet.git" />
<plugin name="cordova-plugin-app-version" spec="https://github.com/whiteoctober/cordova-plugin-app-version.git" />
<plugin name="onesignal-cordova-plugin" spec="~1.12.5" />

Custom Cordova iOS plugin

I'm new in developing with cordova and would like to add a custom written iOS plugin from file system. I use cordova version 4.3.0 with iOS version 3.8.0.
When trying to add the plugin with " $ cordova plugin add ../my_plugin_dir" I get the following error:
Error during processing of action! Attempting to revert...
Failed to install 'at.researchstudio.knowledgepulse.reminder':Error: Uh oh!
".../plugins/at.researchstudio.knowledgepulse.reminder/src/ios/Kpreminder.m" not found!
But the m-source file is in this folder!!! What am I doing wrong??
Plugin-Structure:
at.researchstudio.knowledgepulse.reminder/
plugin.xml
src/
ios/
Kpreminder.h
Kpreminder.m
www/
reminder.js
The plugin.xml looks like the following
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="at.researchstudio.knowledgepulse.reminder" version="0.0.1">
<name>Kpreminder</name>
<description>Reminder Functionalities for KP</description>
<keywords>KnowledgePulse reminder</keywords>
<js-module src="www/reminder.js" name="reminder">
<clobbers target="reminder" />
</js-module>
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="Kpreminder">
<param name="ios-package" value="Kpreminder"/>
</feature>
</config-file>
<header-file src="src/ios/Kpreminder.h" />
<source-file src="src/ios/Kpreminder.m" />
</platform>
</plugin>
I think you may put you plugin in 'plugins'folder,put into other folder
like $project_folder/myplugins/at.researchstudio.knowledgepulse.reminder
then install it

Resources