Ionic 2 : Run a background task - javascript

I try to create a background task for my Ionic 2 app. I found this :
https://ionicframework.com/docs/v2/native/background-mode/
But my IDE doesn't found "backgroundMode" in this line :
cordova.plugins.backgroundMode.enable();
I have install the plugin.
Q : What I have to do to create a function who run when my user doesn't use the app.
And why I have this error ?
Thanks for your help.

Cordova plugins only work in devices. You can not use them on browser during development.
If you want to test that plugin, you should run your app with ionic run android (or ios) with a device plugged to PC or use an emulator. You can also run ionic build and install the debug package on a device.
In development, you can declare cordova variable with declare var cordova:any; at begining of script to avoid IDE errors of cordova being an undefined variable.

Related

How to fix app crashing on IOS devices react-native

I am building for first time an React - Native Application . Until now we have tested the application on the several Android devices and no problem has been detected . But when the application is runned on Ios devices it crashesh almost instantly . So my question is am i doing something wrong ? I followed up the documentetion from the react-native web page and i have done the right installs , but still the problem occurs . Also when i try to build up an Android or IOS simultaor with the command :
react-native run-android
react-native run-ios
It throws me an error :
Android project not found. Maybe run react-native android first?
Or for Ios :
iOS project folder not found. Are you sure this is a React Native project?
Error: iOS project folder not found. Are you sure this is a React Native project?
My folder looks like this :
Am i missing something that should be installed ? Can you givev me some hints ? Thank you !
PandaMastr, the example image indicates that this an expo react native application, to run it you will need to go the root folder and run npm start which will launch the application. In order to use the react-native run commands you would need to eject the application ( always make a backup so you can revert if need be ); which would then create the android and iOS folder and install the react-native run aspects you are attempting to use.

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: fcmPlugin.getToken is not a function [duplicate]

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.

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.

Run cordova phonegap through a specific ide

I would really like if someone of your very well-known community could help me.
Here is what I try to do. I try to run apache cordova through aptana using Ripple and Android Emulator
I am using aptana studio 3 for web development IDE and I try to configure it in order to develop phonegap apps. I have OS Windows 8.1 64
I have Java sdk
I installed Android sdk
I have Node JS
I have the cordova phonegap using npm install -g cordova in the C
I have installed Ripple emulator as plugin in Chrome. In order to run it through aptana I go to the run arrow and I select Run Configurations and making a new configuration using in
Browser Executable: the path for chrome.exe
Arguments: --enable-extensions --allow-file-access-from-files
And run it.
Also I go to Help --> Install New Software in order to take the android developer tools. I click in the right up corner the button Add and I give the name ADT and location https://dl-ssl.google.com/android/eclipse/
Everything work. I tried to insert an existing phonegap project and run it but I have a problem to show the android emulator. Any help how can I do it?
Also any help how I will run a new phonegap example in order to make my own app and test it with Ripple and Android Emulator? Also can I install plugins like org.apache.cordova.splashscreen

Categories

Resources