Phonegap, Cordova - Issue with Plugins - javascript

I have installed Phonegap (3.0.3) and the Cordova CLI.
I am also running iOS as a platform (confirmed using $ cordova platforms ls)
I have installed the plugins ($ cordova plugins ls)
org.apache.cordova.core.dialogs
org.apache.cordova.core.vibration
However, when I run this console command ($ cordova emulate ios), I get the following error.
Undefined symbols for architecture i386:
"_AudioServicesAddSystemSoundCompletion", referenced from:
_playBeep in CDVNotification.o
"_AudioServicesCreateSystemSoundID", referenced from:
_playBeep in CDVNotification.o
"_AudioServicesDisposeSystemSoundID", referenced from:
_soundCompletionCallback in CDVNotification.o
"_AudioServicesPlaySystemSound", referenced from:
_playBeep in CDVNotification.o
-[CDVVibration vibrate:] in CDVVibration.o
"_AudioServicesRemoveSystemSoundCompletion", referenced from:
_soundCompletionCallback in CDVNotification.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
The following build commands failed:
Ld build/MyApp.app/MyApp normal i386
(1 failure)
I have followed the directions from the API page here (http://cordova.apache.org/docs/en/edge/cordova_notification_notification.md.html#Notification) and below is my config.xml file in the MyApp > www > config.xml file which causes the error.
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp.myapp" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>MyApp</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev#callback.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<plugin name="Notification" value="CDVNotification" />
<access origin="*" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
</widget>
Any suggestions what the issue might be, and how I can go about fixing it?

Add AudioToolbox framework in your Xcode project:
Your Target > Build Phases > Link Binary With Libraries
Click the '+' button
Choose AudioToolbox.framework

Did you run cordova build ios?
then cordova emulate ios
This error happen when you don't add the source to the Compile sources in build phase.
Try to add plugins with :
TargetSettings -> Build Phases -> Compile Sources -> add your .m class

Take a look at CDVNotification.h - the #import lines tell you everything you need to add to your compile sources build phase.
Foundation/Foundation.h
UIKit/UIKit.h
AudioToolbox/AudioServices.h
Add those 3, and it will compile.
UPDATE - an additional change is necessary in CDVNotification.m
playBeep() calls soundCompletionCallback()
soundCompletionCallback calls playBeep()
In order for playBeep to be error free, soundCompletionCallback must be declared. The simple solution is to declare it before playBeep, then define it after.
Add this line just before static void playBeep(int count)
// declared but not defined to avoid undeclared error in playBeep
static void soundCompletionCallback(SystemSoundID ssid, void* data);

Related

how to run cordova project in manjaro

I have problem using cordova, I new in cordova, well, my problem is whe I try run the project is show me an error. like this:
FAILURE: Build failed with an exception.
* Where:
Settings file
'/home/ngel/Projects/cordova_lab/novaCrud/platforms/android/settings.gradle'
* What went wrong:
Could not compile settings file
'/home/ngel/Projects/cordova_lab/novaCrud/platforms/android/settings.gradle'.
> startup failed:
General error during semantic analysis: Unsupported class file major version 61
java.lang.IllegalArgumentException: Unsupported class file major version 61
first a create project like this:
cordova create testprj
then add platform
cordova platform add android
and finally
cordova run android
and show me the error above.
my gradle is 6.9.1,
OS manjaro
please help me.
thanks for your advice.

PhoneGap - Trouble installing cordova-plugin-wkwebview-engine-localhost plugin

I have been working on a javascript project, the client requires it to be published to the AppStore. We chose to work with PhoneGap as it did a lot of the work for us and the results were satisfactory. However the performance on some apple devices was a poor compared to the application running just on Safari.
After doing some reading into UIWebView and how its deprecated, I decided to give the WKWebView a go hoping that the performance would be at least a little better.
I successfully installed the cordova-plugin-wkwebview-engine which then led me to the XHR issues that I have seen many people having. However I found a solution via this post https://stackoverflow.com/a/42953116/10551718
The issue I am having is when I try and replicate what this gentleman has done, I get errors in the PhoneGap build regarding cordova-plugin-wkwebview-engine-localhost saying that it can't clone the git repository.
Build Date: 2018-10-24 04:20:25 -0700
--------------------------------------------------------------------------------
PLUGIN OUTPUT
--------------------------------------------------------------------------------
Fetching plugin "cordova-plugin-splashscreen" via npm
Installing "cordova-plugin-splashscreen" at "5.0.2" for ios
Fetching plugin "cordova-plugin-wkwebview-engine" via npm
Installing "cordova-plugin-wkwebview-engine" at "1.1.4" for ios
"plugman-151 install --platform ios --project /project --plugin https://github.com/apache/cordova-plugins.git#wkwebview-engine-localhost --nohooks=.": Fetching plugin "https://github.com/apache/cordova-plugins.git" via git clone
Using shallow clone
Repository "https://github.com/apache/cordova-plugins.git" checked out to git ref "wkwebview-engine-localhost" at "a3cc931".
Installing "cordova-labs-wkwebview-engine-localhost" at "0.5.1" for ios
Fetching plugin "git+https://github.com/apache/cordova-plugins.git" via git clone
Cloning full repository
Failed to install 'cordova-labs-wkwebview-engine-localhost': Error
at /.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/pgb-cordova-lib/src/plugman/fetch.js:100:37
at _rejected (/.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:864:24)
at /.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:890:30
at Promise.when (/.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:1142:31)
at Promise.promise.promiseDispatch (/.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:808:41)
at /.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:624:44
at runSingle (/.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:137:13)
at flush (/.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:95:7)
at process._tickCallback (internal/process/next_tick.js:161:9)
Failed to fetch plugin git+https://github.com/apache/cordova-plugins.git via git.
Either there is a connection problems, or plugin spec is incorrect:
Error: git: Command failed with exit code 128 Error output:
Cloning into '/var/folders/lt/xxbrk07x45bdj1fl3wjgf8yc0000gn/T/git/1540380025411'...
fatal: Unable to find remote helper for 'git+https'
I have this in my config...
<plugin name="cordova-plugin-splashscreen" source="npm" />
<plugin name="cordova-plugin-wkwebview-engine" source="npm" />
<plugin name="cordova-plugin-wkwebview-engine-localhost" spec="https://github.com/apache/cordova-plugins.git#wkwebview-engine-localhost" />
<content src="http://localhost" />
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
Any help would be greatly appreciated!
I ended up finding an alternative plugin - https://github.com/ionic-team/cordova-plugin-ionic-webview
This installed with no issues and correctly forced the WKWebView which lead to a massive performance increase!

Ionic 3 - Error when adding or building iOS app

I get the following error when building or adding ios with ionic cordova build ios or ionic cordova platform add ios. The build works fine for Android.
IOS project now has deployment target set as: 8.0
IOS project Code Sign Entitlements now set to: App/Resources/App.entitlements
Entitlements file is not in references section, adding it
{ Error: ENOENT: no such file or directory, open '/Users/cipriancirstea/Documents/ionic_app/ul_web_hooks/ios/https:/t4edc.app.goo.gl/#apple-app-site-association'
at Object.fs.openSync (fs.js:667:18)
at Object.fs.writeFileSync (fs.js:1326:33)
at saveContentToFile (/Users/cipriancirstea/Documents/ionic_app/plugins/cordova-universal-links-plugin/hooks/lib/ios/appleAppSiteAssociationFile.js:118:8)
at /Users/cipriancirstea/Documents/ionic_app/plugins/cordova-universal-links-plugin/hooks/lib/ios/appleAppSiteAssociationFile.js:72:5
at Array.forEach (<anonymous>)
at createNewAssociationFiles (/Users/cipriancirstea/Documents/ionic_app/plugins/cordova-universal-links-plugin/hooks/lib/ios/appleAppSiteAssociationFile.js:70:27)
at Object.generate (/Users/cipriancirstea/Documents/ionic_app/plugins/cordova-universal-links-plugin/hooks/lib/ios/appleAppSiteAssociationFile.js:45:3)
at activateUniversalLinksInIos (/Users/cipriancirstea/Documents/ionic_app/plugins/cordova-universal-links-plugin/hooks/afterPrepareHook.js:85:29)
at /Users/cipriancirstea/Documents/ionic_app/plugins/cordova-universal-links-plugin/hooks/afterPrepareHook.js:50:11
at Array.forEach (<anonymous>)
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/Users/cipriancirstea/Documents/ionic_app/ul_web_hooks/ios/https:/t4edc.app.goo.gl/#apple-app-site-association' }
config.xml
<universal-links>
<host name="https://t4edc.app.goo.gl/" scheme="https" />
<host name="example-902cc.firebaseapp.com" scheme="https">
<path url="/__/auth/callback" />
</host>
</universal-links>
This is error occurs because you have https:// prepended to the host name.
To get rid of the error, simply replace this:
<host name="https://t4edc.app.goo.gl/" scheme="https" />
with this:
<host name="t4edc.app.goo.gl/" scheme="https" />
The reason behind the error is that the plugin automatically creates files under ul_web_hooks/ios/ and the files are named by the corresponding host name. On MacOs (on *nix platforms in general), colon (:) is not allowed to be a part of the file path.
Hope that helps! Good luck!
Based on the output it looks like you are trying to build on a Windows operating system.
Unfortunately You need an apple or Mac Operating System with Xcode in order to do a proper build for IOS devices.
For Reference

Cordova Android Build Failure ("failed to find Build Tools revision 24.0.1")

I'm having trouble building my Cordova project with Android. When I typed "cordova build Android", this is the result:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find Build Tools revision 24.0.1
I checked my SDK manager and the build tools version 24.0.1 are installed. I was building earlier just fine so I'm not sure what changed. Any help would be appreciated. Thanks!
I'd start by making sure that your PATH environment/system variable includes paths to the various Android tools, and also that you have an ANDROID_HOME entry pointing to the SDK
Partial PATH example (on Windows):
C:\Program Files (x86)\Android\android-sdk\tools;
C:\Program Files (x86)\Android\android-sdk\platform-tools;
ANDROID_HOME example (on Windows):
C:\Program Files (x86)\Android\android-sdk

Phonegap media: "Reference error media not defined "

This question answered many times, but I still can't fix my problem. I'm trying to play a music when my scene starts, I'm using Media class, but I get the error ReferenceError: Media is not defined. I'm using browser yet (I want to deploy it to android and ios later).
I'm using Cordova 3.5, PhoneGap 3.6.
Here's what I did so far:
1
ran the command in the command line standing in my project directory: cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git
2
modified the config xml:
<feature name="Media">
<param name="android-package" value="org.apache.cordova.media.AudioHandler" />
</feature>
3
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
My js code is:
var music = new Media("sounds/main_theme.ogg");
Instead of using PhoneGap via this tutorial, rather use command line cordova via this tutorial.

Categories