Ionic AppRate fails, incomplete object? - ionic-framework

I am trying to add AppRate to my app based on the
https://ionicframework.com/docs/v3/native/app-rate/
example
TypeError: AppRate.preferences.openUrl is not a function. (In
'AppRate.preferences.openUrl(iOSStoreUrl)', 'AppRate.preferences.openUrl' is undefined)
That method is indeed missing on the object when inspected in debugger.
On the plugin documentation they add the method manually.
https://github.com/pushandplay/cordova-plugin-apprate
This approach fails for me however, too. My ionic app has no window object.

I had the same issue, but in ionic 4.
I solved it, firstly, reinstall the plugin from git repository or cordova plugins registry (to make sure we have the function openUrl added) and adding the missing method to #ionic-native/app-rate/ngx/index.d.ts like :
export interface AppRatePreferences {
...
...
...
openUrl?:(url:string) => void;
}
And after where you have used the call of the plugin, you add openUrl: appRate.preferences.openUrl to preferences properties like :
appRate.preferences = {
displayAppName: '',
storeAppURL: {
ios: '<my_app_id>',
android: 'market://details?id=<package_name>',
windows: 'ms-windows-store://pdp/?ProductId=<the apps Store ID>',
blackberry: 'appworld://content/[App Id]/'
},
openUrl: appRate.preferences.openUrl
};
Hope it helps you.

For ionic 3, Make sure the latest versions are installed with support for #ionic-native/app-rate#4
In my case I have solved it by installing version 4 of #ionic-native and version 1.4.0 of apprate.
Try this:
$ ionic cordova plugin rm cordova-plugin-apprate
$ ionic cordova plugin add cordova-plugin-apprate#1.4.0 --save --exact
$ npm install --save #ionic-native/app-rate#4

Related

Why is my Facebook and Ionic Capacitor integration having problems?

We are attemptin to integrate the facebook SDK for analytics into an Ionic/Capacitor app. Obviously, when following the install instructions here`, it is not possible to run the command
ionic cordova plugin add cordova-plugin-facebook-connect --variable APP_ID="123456789" --variable APP_NAME="myApplication"
We have tried installing using NPM, however when running it seems unable to locate the App ID and the App Name on Android, returning these errors:
AAPT: error: resource string/fb_app_id (aka capacitor.android.plugins:string/fb_app_id) not found.
I have tried using the Facebook Capacitor Analyzer plugin found here but that just caused more issues.
Surely someone out there has achieved this integration? Am I missing something? I have declared the App_ID and name in a strings.xml file - but it looks within a seperate AndroidManifest.xml file located inside the capacitor-cordova-android-plugins folder, which is generated when built.
Please help, any advice would be amazing
Is your app Capacitor or Cordova?
Because in capacitor apps, Cordova hooks don't work & you have to manually edit the Native Project Files or set the capacitor config file instead.
i.e. setting these variables in the console does not work.
--variable APP_ID="123456789"
--variable APP_NAME="myApplication"
please also check out the related SO post.
You can, however, use the capacitor configuration file & set the preferences here. example capacitor config:
{
appId: "com.myapp.app",
appName: "myApplication",
cordova: {
preferences: {
APP_ID: "123456789",
APP_NAME: "myApplication"
}
}

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.

Modify cordova plugin - app not see changes

I need to modify cordova-plugin-media, but when I run app with ionic cordova run android my changes are not applied.
How should I modify and run plugin correctly?
I found the answer.
cordova files should be edited in /plugins folder, not in /node_modules
after editing, I should do: ionic cordova platform rm android and ionic cordova build android
After that modifications work.
You should paste some code, showing the code of app module and config.xml.
But basically you should only do:
ionic cordova plugin add cordova-plugin-media
npm install --save #ionic-native/media
And then add your plugin to the project into file
App.module.ts:
import { Media } from '#ionic-native/media';
...
providers: [
....
Media,
...
]
And that's it, then you should be able to use the functionalities inside your components.

Can't run Ionic on Android: class not found exception IonicKeyboard

After building and running android app it closes.
Viewing Eclipse logcat it shows a class not found exception com.ionic.keyboard.IonicKeyboard
I'm new with Ionic and I don't know how to make it work. Thanks in advance
I had the same problems.
In my case the plugin was already installed, so I had to remove and add it again:
Try this in your app-folder:
cordova plugin remove com.ionic.keyboard
and
cordova plugin add com.ionic.keyboard
npm changed plugin names. Now it should be
cordova plugin add ionic-plugin-keyboard
Try this in your app-folder:
cordova plugin remove ionic-plugin-keyboard
and
cordova plugin add ionic-plugin-keyboard
Seems that plugin not installed?
Try in cmd:
cordova plugin add com.ionic.keyboard

Phonegap add plugin fails (errno 34) */plugin.xml

When I add a plugin to a 3.0.0 phonegap project with an android platform, I have an error eventhough a bunch of files for the plugin are added. In addition to that error when I add it, the Android manifest never gets updated with the right authorizations.
$ cordova plugin ls
No plugins added. 'Use cordova plugin add <plugin>'.
$ sudo cordova plugin add "http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git"
{ [Error: ENOENT, no such file or directory '/tmp/plugman-tmp1375200648427/*/plugin.xml']
errno: 34,
code: 'ENOENT',
path: '/tmp/plugman-tmp1375200648427/*/plugin.xml',
syscall: 'open' }
$ cordova plugin ls
[ 'org.apache.cordova.core.media-capture' ]
I was having the same problem with the Connection plugin. Once I changed from "cordova plugin add" to "phonegap local plugin add", it worked fine.
$ phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git
I had the same problem, after some debugging and testing I finally solved the problem:
Open
C:\Users\<user>\AppData\Roaming\npm\node_modules\cordova\node_modules\plugman\src\util\plugins.js.
Find var cmd = util.format('git clone "%s" "%s"', plugin_git_url,
path.basename(tmp_dir)); (line 42 ATM)
Replace it with var cmd = util.format('git clone "%s"
"%s"', plugin_git_url, tmp_dir);.
This will make git clone clone to the absolute tmp path instead of the relative.
I received a similar error. I resolved the issue by removing the media-capture plugin, installing the file plugin, then reinstalling the media-capture plugin
cordova plugin rm org.apache.cordova.media-capture
cordova plugin add org.apache.cordova.file
cordova plugin add org.apache.cordova.media-capture
Maybe media-capture is dependent on the file plugin.
I was also facing the same error :
Suppose if you want to add camera plugin then instead of giving:
cordova plugin add cordova-plugin-camera
use
phonegap plugin add cordova-plugin-camera
and then it will work fine
It turns out i had something really strange with my proxy. Possibly some data compression on the fly which made the data corrupt. Tethering from the phone solved the issue, after completely uninstalling cordova.