Cordova: fcmPlugin.getToken is not a function [duplicate] - javascript

I am trying to use the cordova-plugin-health plugin for a phonegap app I am working on. Whenever I use the app every plugin works but this one. I am using the phonegap mac app to test on an iPhone 6s.
Steps I have taken:
Installed plugin with cordova plugin add cordova-plugin-health --variable HEALTH_READ_PERMISSION='App needs read access' --variable HEALTH_WRITE_PERMISSION='App needs write access' also I did cordova platform add ios
Used navigator.health.requestAuthorization later on tried window.plugin.health.requestAuthorization my ide WebStorm was able to detect the second but not the first.
Is there anything I missed/can I use this plugin using the phonegap mac app?
Thanks!

Phonegap Developer App is a tool to easily preview your apps.
Phonegap Developer App is a Cordova app itself, that loads your app code from a local web server.
The thing about the Phonegap Developer App is, as it's a precompiled app, it can only run the plugins that were included on the Phonegap Developer App at the moment of the build.
That means, most 3rd party plugins (like the heathkit one) won't work as they are not included in the Phonegap Developer App.
What you can do is to run your app in your device instead of previewing it.
To do it, run, with the Phonegap CLI installed and your device plugged in:
phonegap run ios
If you have Cordova CLI installed, this should also work
cordova run ios.

Related

Adding Cordova Platforms

Hey, Guys! I recently started to work with Cordova and when I run the Cordova platform add android i get the following error. I have successfully placed the environment variables for Java and for the Android SDK as well. But the npm modules does not exist in C:/Windows/System32/npm as shown in the error, It is in the Users/My username/AppData/Roaming/npm folder. Some guidance would be appreciated.
I followed the following scripts which are shown in the official Cordova documentation to create a new project.
Cordova create hello com.example.hello HelloWorld
cd hello
Cordova platform add android -> where I'm stuck at
Kindly Check the Android Version Provided by Cordova and verify with your current Android version installed on your system , if there a mismatch :
1) Update Android Version From Android Studio SDK Manager
2) Update Cordova Platform - Refer: Cordova Documentation
External Source
cordova - Error: Failed to fetch platform android
I figured out halfway what the the problem was. There was a file named 'npm' in my C:/Windows/System32 directory wich was of 0kb size, and once i deleted it, the error vanished. But not all the way though. I was able to install the browser platform but not the android platform via cordova platform add android or even specifying what the matching cordova-andriod pluggin to be with cordova platform add andriod#version.
Only through the cordova platform add https://github.com/apache/cordova-android.git script I could install the andriod platform and once it was done other steps worked fine, and the project ran through the Android AVD. Any idea why the normal command to add the android platform didnt work, Just want to know but if it happens again i think Im gonna have to run the get from git command again. Thanks

Cordova/Phonegap app is not showing the changes I've made in the jade files

I'm using grunt to show my changes that I've made in sublime text. But whenever i use cordova prepare, cordova build android, and cordova run android it only shows the previous version of the app on the emulator and my android device.
my changes were not navigating to the cordova folder because I didn't run grunt build-ios in the command line.

Inappbrowser issue in worklight hybrid application in android devices

I have created worklight 6.2 hybrid application for android in which when user clicks on a button it has to open an Inappbrowser with external url. Below is the code I have used on click of a button:
$("#inapp").click(function(){
window.open("https://xxxx.com","_blank","location=yes");
});
When I click on the button the application closes by displaying a pop up with an error message:
Unfortunately, sampleApp stopped
This is happening only in android devices, in iOS it is working fine.
This is a known issue with missing resources. The current workaround is to create a standalone Cordova 3.4 Android application with the Cordova Command Line Interface.
This will NOT be a replacement of your Worklight application - it will allow you to generate the resources you are missing.
Workaround instructions:
--> Android Platform Guide:
http://cordova.apache.org/docs/en/3.4.0/guide_platforms_android_index.md.html#Android%20Platform%20Guide
In the "Requirements and Support" section, follow the steps to include the Android SDK's tools and platform-tools directories in your PATH environment and to enable Java and Ant.
--> The Command-Line Interface:
http://cordova.apache.org/docs/en/3.4.0/guide_cli_index.md.html#Plugin%20Development%0AGuide
Follow the steps under "Prerequisites" then do the following commands:
cordova create hello com.example.hello "HelloWorld"
cd hello
cordova platform add android
cordova plugin add org.apache.cordova.inappbrowser
cordova build
--> Android Platform Guide: Follow the steps under "Open a Project in the SDK"
Now you can navigate to the files you need, which will be in:
\hello\platforms\android\res\drawable-hdpi
Copy the 3 ic_action PNG files into the \native\res\drawable-hdpi directory of your Worklight 6.2 project:
ic_action_next_item.png
ic_action_previous_item.png
ic_action_remove.png
This should fix the issue and allow the application to run successfully.
Here is a technote on this issue: http://www-01.ibm.com/support/docview.wss?uid=swg21681060

Cordova vs Phonegap on Plugin, Support, Documentation, Updates

Knowing that Phonegap is built on top of Cordova.
I am having several issues with Phonegap after trying out different versions
phonegap is poorly documented as lot of their guides are still using Cordova cli, which should be switched to phonegap. Just see their guide on 3.2 and 3.4. 3.2 the website uses phonegap on cli, 3.4 it uses back Cordova on cli.
When building Phonegap 3.4 on eclipse, it is fine. But on Phonegap 3.3, the build process will always replace default files with those I have implemented or amended.
Plugin like pushplugin fails on phonegap 3.3 and 3.4 (is it only me?), there is no support or response in the forum
Any new updates on Cordova, we will have to wait for Phonegap for integration. Which in turns will creates bugs in our Phonegap plugins
Now i am thinking to use solely Cordova. But I have few inquires.
Can Cordova uses the plugin from Phonegap
Can Phonegap uses the plugin from Cordova
Is it worth for the conversion from Phonegap to Cordova? Is Cordova more stable then Phonegap in terms of support, updates and plugin availability?
Which tools have more users? Phonegap or Cordova ?
Can Cordova be compile through cloud? This is important as I do not own a MAC for building ios application.
It is completely worth it to change from phonegap to cordova.
1>Can Cordova uses the plugin from Phonegap or 2>Can Phonegap uses the plugin from Cordova
As phonegap is build on top of cordova,All pluging available for phonegap is available in cordova.Infact phonegap uses many of cordova's plugins,it downloads from cordova's library when you try to download
3>Is it worth for the conversion from Phonegap to Cordova? Is Cordova more stable then Phonegap in terms of support, updates and plugin availability?
It is completely worth the transformation,because cordova is more stable and we have a new version for every single issue reported. The newer phonegap versions are basically build on top of newer cordova versions .
4>Which tools have more users? Phonegap or Cordova ?
Both tools have more or less equal number of users although Iam slightly biased towards cordova .The users who can afford set up of all platforms prompt towards cordova and others towards phonegap.
5>Can Cordova be compile through cloud? This is important as I do not own a MAC for building ios application
No there is no tool to compile a cordova project through cloud.Although I once tried uploading the www folder of cordova into phonegap cloud and got a perfect build for IOS and Android.You can try this with a sample cordova project and if you are satisfied with the result you can migrate to cordova
Here is a link to the Cordova plugin registry http://plugins.cordova.io/#/ . I believe all plugins that work for Phonegap will work Cordova. PhoneGap only has a few plugins available for Build because they have to check to make sure the plugin will work with their system but those plugins will still work in Cordova. Phonegap and Cordova are basically the same. Phonegap is just owned by Adobe and the major difference is that Phonegap has Phonegap Build. I do not believe that Cordova can be complied through cloud tho I could be wrong about that. There are several other cross platform tools you may want to look into if you are not comfortable with Cordova and Phonegap such as appgyver or kivy.

Phonegap Build process for development

There is so much conflicting information out there on this, I'm hoping we can shed some light.
Goal: Create and develop a phonegap app that will be built using phonegap build.
1) I don't want to install the android and iOS SDKs, that's why I want to use phonegap build.
2) I created an app using the cordova cli cordova create hello
3) There is no phonegap.js or cordova.js I guess because I didn't add a platform. But I don't want to add a platform as that requires installing the SDKs
4) I need to be able to debug and test this, so I downloaded ripple, which may or may not work, I need the phonegap.js file first to see.
So has anyone figured this out? Building and developing and app that will be used on Phonegap build?
Thanks!
Phonegap will let you create a UI using webview of Android, iOS, Blackberry or other platforms. That means you need to have native SDK to apply Phonegap Build. It doesn't mean that Phonegap will create an App for you and deploy it to other platforms.

Categories

Resources