Media plugin not installed? Ionic 3 - ionic-framework

I have an Ionic 3 app that requires to use Media Plugin.
When I press the "record" button on my app, this code block is executed:
this.platform.ready().then(() => {
this.fileName = this.commentsProvider.getFileName(this.platform);
this.filePath = this.commentsProvider.getFilePath(this.platform, this.fileName);
this.audio = this.media.create(this.filePath);
this.audio.startRecord();
this.recording = true;
});
And it doesn't works. The console throws:
console.warn: Native: tried accessing the Media plugin but it's not installed.
NOTE: I'm runing the app in a connected Android device, via USB.
You can see I'm using platform.ready() and anyway I still have this problem.
Any idea?
Thank's in advance!
EDIT: I've already deleted node_modules and plugins folders, and ran npm install, and the problem persists.

Related

Issue when I use ionic cordova run android

I am getting an issue when I try to run with command line
ionic cordova run android
The error that it diplays is this one:
ERR_NO_TARGET: No targets devices/emulators available. Cannot create AVD because there is no suitable API installation. Use --sdk-info to reveal missing packages and other issues.
But the thing is that I created a device in the Android Studio:
so I wonder what could the problem be? Thanks
You need to launch the emulator and keep it running before executing the command ionic cordova run android
Click on the Play icon in the Virtual Devices list to launch the emulator.
Might not be the answer you're looking for but generally, I use:ionic cordova build android
Then open the platform/android directory in Android Studio.
Maybe you should try this :
for see avaliables devices this:
ionic cordova run android --list
for run android app on device this:
ionic cordova run android --device --verbose
i hope help you.
Make sure you have the following variables set in your environment.
export ANDROID_HOME=$HOME/Library/Android/sdk
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export ANDROID_AVD_HOME=$HOME/.android/avd

How to use fabric js (html5-Canvas Library) custom build in ionic project

I am working in ionic application that enable to create graphics.
I am using fabric js letest version 3.2.0 and want ot use touch gesture.
I try to clone fabric js repository into my pc and try to build custom build using following command :
node build.js modules=ALL
So, build is successful in dist folder, but I don't know how to install it in ionic.
Please help me.
After compare all file in node-module/fabric and my custom build. and I got that both are same.
So I put this answer for help.
Step :
install letest fabric js using cmd : npm install fabric --save
download custom build from fabric js site : http://fabricjs.com/build/
open : ionic-project-folder/node modules/fabric/
replace dist folder Placed inside above path with downloaded custom build (dist folder)
re-serve project.
If any other solution is possible (like publishing into npm and install) then Please mention.
This is a link to Ionic's API for interacting with the Crashlytics kit: https://ionicframework.com/docs/v3/native/crashlytics/. This should have the instructions needed to get your Ionic app integrated with Crashlytics.
install via npm
npm i fabric
more details go to
https://www.npmjs.com/package/fabric
For my case, I'm using a custom build fabric js version 5.2.4 with an Ionic 6 application.
Uninstall fabric js if you are installed it in your project with npm uninstall fabric
Download your custom build from fabric js site : http://fabricjs.com/build/
Add the downloaded file to public directory. For example public/libs/fabric/fabric.min.js
At App.js
useEffect(() => {
const script = document.createElement('script');
// You may have to replace this code with your path.
script.src = "libs/fabric/fabric.min.js";
script.async = true;
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
}
}, []);
re-serve project.
Now fabric should be available from window.fabric
Note.
The editor also add some code to my tsconfig.json
"include": [
"src",
"public/libs" // This code
]
I do not know what it does but it works fine so I leave it.

deviceready did not fire within 5000ms - ionic Native with onesignal

I am using one signal plugin for push notification.
First i installed the one signal plugin.
ionic cordova plugin add onesignal-cordova-plugin
npm install --save #ionic-native/onesignal
Here is my code
this.platform.ready().then(() => {
this.oneSignal.getIds().then((ids)=>{
console.log("USER ID");
console.log(ids.userId);
}).catch((e)=>{
console.log("error")
console.log(e);
})
})
But does not get app id.why?
The error is plugin_not_installed.
I remove this plugin again added.
But still get the same error. and also getting this type of err.
Ionic Native: deviceready did not fire within 5000ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.
Native: deviceready did not fire within 5000ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.
Kindly advice me,
Thanks.

How to access to the photo gallery in ionic?

I'm facing an issue using ionic creator, how can I upload an image from the phone gallery ?
What I tried (most relevant tries) :
followed this tutorial : https://forum.ionicframework.com/t/how-to-user-ngcordova-with-ionic-creator/68619/2 to set the environnement with "ionic-native.min.js".
=> Get : Uncaught SyntaxError: Unexpected token (
ionic.bundle.js:13443 Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
Tried to use "imagepicker" (without the warranty that I really have installed the plugin in my environnement, because in the creator I can't install sources from the web. So, crossed fingers and hope "ionic-native.min.js" provides it.) : https://ionicframework.com/docs/native/image-picker/
=> still not working.
An finally I tried this : http://blog.ionic.io/ionic-native-accessing-ios-photos-and-android-gallery-part-2/
=> For the exact same result : white screen and errors.
I'm testing the app with both the web browser emulator (which I know sometimes doesn't work with cordova functions) and the ionic creator app on iphone. I'm sure someone have already faced and succeed this problem, thank you guys.
All you have to do is adding cordova-plugin-camera to your project, it should works like a charm (Ionic 2.x) :
ionic cordova plugin add cordova-plugin-camera

cordova 3.4 file 1.0.1 resolveLocalFileSystemURI android issue

I am trying to get a full path to an image retrieved from Android image library. via the camera plugin.
window.resolveLocalFileSystemURI("content://media/external/images/media/83", function(fileEntry) {
or
window.resolveLocalFileSystemURL(imageURI, function(fileEntry) {
fileEntry.file(function(fileObj) {
newimageURI = fileObj.fullPath;
alert(newimageURI);
});
});
returns undefined.
There was updates the other day and it is no longer working. I have tried toURL() as well with no success.
Try removing the file plugin and adding it again. Works for me. I think it's related to this bug: Cordova iOS Plugins fail after building, unless I remove platform and plugin JSON first