emi-indo-cordova-plugin-fanalytics
Version:
Cordova Plugin Firebase Analytics support consent and admob
167 lines (121 loc) • 3.97 kB
Markdown
# emi-indo-cordova-plugin-fanalytics
### Cordova Plugin Firebase Analytics support consent and AdMob
### Support Capacitor
## [full example ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-fanalytics/tree/main/example/www)
> [!NOTE]
> - To maintain this plugin in the long run,
> - for (regular maintenance),
> - just give me a cup of coffee.
## 💰Sponsor this project
[](https://paypal.me/emiindo)
[](https://ko-fi.com/F1F16NI8H)
## This plugin comes with a hook
- so this is not required `<resource-file src=“www/google-services.json” target=“app/google-services.json” />`
- just add `google-services.json` or `GoogleService-Info.plist` to the `www folder` and it will run automatically.
## Minimum Cordova Engines
- cordova version = 10.0.0
- cordova-android version = 11.0.0
- cordova-ios version = 6.0.0
> [!NOTE]
> - Android only, IOS I have not updated yet
## Features
- setEnabled
- setSessionTimeoutDuration
- logEvent
- logEventSelectContent
- setUserId
- setUserProperty
- resetAnalyticsData
- setCurrentScreen
- setDefaultEventParameters
- setConsent
- setAdMobRevenuePaid
# Installation Capacitor
- project confirmation ( Android )
- add file ```google-services.json ``` inside the www folder
- project confirmation ( IOS )
- add file ```GoogleService-Info.plist ``` inside the www folder
## Installation plugin
```sh
npm i emi-indo-cordova-plugin-fanalytics
```
### add node to package.json
```sh
"scripts": {
.....
.....
"update-analytics": "node node_modules/emi-indo-cordova-plugin-fanalytics/hooks/capacitor-config-hooks.js",
.....
.....
},
```
### Run the Hook script
```
npm run update-analytics
```
### Plugin Synchronization: Run the following command to synchronize the Cordova plugin to the Capacitor project:
```
npx cap sync
```
### Optional (capacitor-config-variable.js)
- Value true by default
- If you want to change it to false
- add in capacitor.config.json
```
{
"appId": "io.cordova.hellocordova",
"appName": "HelloCordova",
"webDir": "www",
"bundledWebRuntime": false,
"plugins": {
"Analytics": {
"ANALYTICS_COLLECTION_ENABLED": "false", // Customize with needs true | false
"AUTOMATIC_SCREEN_REPORTING_ENABLED": "false", // Customize with needs true | false
"DEFAULT_ALLOW_ANALYTICS_STORAGE": "false", // Customize with needs true | false
"DEFAULT_ALLOW_AD_STORAGE": "false" // Customize with needs true | false
}
}
}
```
### add node to package.json
- capacitor-config-variable.js
```sh
"scripts": {
.....
.....
"update-analytics": "node node_modules/emi-indo-cordova-plugin-fanalytics/hooks/capacitor-config-hooks.js",
"update-analytics-variable": "node node_modules/emi-indo-cordova-plugin-fanalytics/hooks/capacitor-config-variable.js",
.....
.....
},
```
### Run the Hook script
```
npm run update-analytics-variable
```
# Installation Cordova
```sh
cordova plugin add emi-indo-cordova-plugin-fanalytics
```
### Or
```sh
cordova plugin add https://github.com/EMI-INDO/emi-indo-cordova-plugin-fanalytics
```
## Remove
```sh
cordova plugin rm emi-indo-cordova-plugin-fanalytics
```
## project confirmation (ANDROID)
- add file ```google-services.json ``` inside the www folder
## project confirmation ( IOS )
- add file ```GoogleService-Info.plist ``` inside the www folder
- After the plugin has been added run the`
- ```cordova prepare```
### Then from the command line run: cd/path/platform/ios
- ```pod install --repo-update```
- wait for the pod to finish installing
- open file ```YourProject.xcworkspace``` ( Or open ```YourProject.xcworkspace``` file from Xcode )
## This plugin was outdated at first, because it was not maintained, now I am maintaining it again.
## Support Platform
- Android
- IOS