Skip to content

Updating the plugin with last frameworks and features #1021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 7 additions & 69 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ matrix:
language: android
android:
components:
- tools-26.0.0
- platform-tools-26.0.0
- build-tools-26.0.0
- android-26.0.0
- tools-28.0.0
- platform-tools-28.0.3
- build-tools-28.0.3
- android-28.0.0
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
Expand All @@ -26,77 +26,15 @@ matrix:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+
env: CORDOVA_VERSION="6.5.0" CORDOVA_PLATFORM="android" CORDOVA_PLATFORM_VERSION="6.4.0"

- os: linux
sudo: false
language: android
android:
components:
- tools-26.0.0
- platform-tools-26.0.0
- build-tools-26.0.0
- android-26.0.0
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
addons:
apt:
packages:
- oracle-java8-installer
- oracle-java8-set-default
licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+
env: CORDOVA_VERSION="7.1.0" CORDOVA_PLATFORM="android" CORDOVA_PLATFORM_VERSION="7.1.0"

- os: linux
sudo: false
language: android
android:
components:
- tools-26.0.0
- platform-tools-26.0.0
- build-tools-26.0.0
- android-26.0.0
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
addons:
apt:
packages:
- oracle-java8-installer
- oracle-java8-set-default
licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+
env: CORDOVA_VERSION="8.0.0" CORDOVA_PLATFORM="android" CORDOVA_PLATFORM_VERSION="7.1.0"
env: CORDOVA_VERSION="8.1.2" CORDOVA_PLATFORM="android" CORDOVA_PLATFORM_VERSION="7.1.4"

- os: osx
language: objective-c
osx_image: xcode9.4
env: CORDOVA_VERSION="6.5.0" CORDOVA_PLATFORM="ios" CORDOVA_PLATFORM_VERSION="4.5.4"

- os: osx
language: objective-c
osx_image: xcode9.4
env: CORDOVA_VERSION="7.1.0" CORDOVA_PLATFORM="ios" CORDOVA_PLATFORM_VERSION="4.5.4"

- os: osx
language: objective-c
osx_image: xcode9.4
env: CORDOVA_VERSION="8.0.0" CORDOVA_PLATFORM="ios" CORDOVA_PLATFORM_VERSION="4.5.4"

- os: linux
env: CORDOVA_VERSION="6.5.0" CORDOVA_PLATFORM="browser" CORDOVA_PLATFORM_VERSION="5.0.3"

- os: linux
env: CORDOVA_VERSION="7.1.0" CORDOVA_PLATFORM="browser" CORDOVA_PLATFORM_VERSION="5.0.3"
env: CORDOVA_VERSION="8.1.2" CORDOVA_PLATFORM="ios" CORDOVA_PLATFORM_VERSION="4.5.5"

- os: linux
env: CORDOVA_VERSION="8.0.0" CORDOVA_PLATFORM="browser" CORDOVA_PLATFORM_VERSION="5.0.3"
env: CORDOVA_VERSION="8.1.2" CORDOVA_PLATFORM="browser" CORDOVA_PLATFORM_VERSION="5.0.3"

before_install:
- nvm install 8
Expand Down
31 changes: 8 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,19 @@ This plugin brings push notifications, analytics, event tracking, crash reportin

## Installation
Install the plugin by adding it to your project's config.xml:
```
<plugin name="cordova-plugin-firebase" spec="^2.0.0" />

```xml
<plugin name="cordova-plugin-firebase" spec="^2.1.0" />
```
or by running:
```
cordova plugin add cordova-plugin-firebase --save

```shell
$ cordova plugin add cordova-plugin-firebase --save
```

### Guides
Great installation and setup guide by Medium.com - [https://medium.com/@felipepucinelli/how-to-add-push...](https://medium.com/@felipepucinelli/how-to-add-push-notifications-in-your-cordova-application-using-firebase-69fac067e821)

### Setup
Download your Firebase configuration files, GoogleService-Info.plist for iOS and google-services.json for android, and place them in the root folder of your cordova project. Check out this [firebase article](https://support.google.com/firebase/answer/7015592) for details on how to download the files.

```
- My Project/
platforms/
plugins/
www/
config.xml
google-services.json <--
GoogleService-Info.plist <--
...
```

###### IMPORTANT NOTES
- This plugin uses a hook (after prepare) that copies the configuration files to the right place, namely `platforms/ios/\<My Project\>/Resources` for ios and `platforms/android` for android.
Expand All @@ -42,10 +31,6 @@ Download your Firebase configuration files, GoogleService-Info.plist for iOS and
### PhoneGap Build
Hooks do not work with PhoneGap Build. This means you will have to manually make sure the configuration files are included. One way to do that is to make a private fork of this plugin and replace the placeholder config files (see `src/ios` and `src/android`) with your actual ones, as well as hard coding your app id and api key in `plugin.xml`.

### Google Play Services
Your build may fail if you are installing multiple plugins that use Google Play Services. This is caused by the plugins installing different versions of the Google Play Services library. This can be resolved by installing [cordova-android-play-services-gradle-release](https://github.com/dpa99c/cordova-android-play-services-gradle-release).

If your build is still failing, you can try installing [cordova-android-firebase-gradle-release](https://github.com/dpa99c/cordova-android-firebase-gradle-release). For more info, read the following [comment](https://github.com/dpa99c/cordova-plugin-request-location-accuracy/issues/50#issuecomment-390025013) about locking down the specific versions for play services and firebase. It is suggested to use `+` instead of `15.+` to ensure the correct versions are used.

## Google Tag Manager

Expand All @@ -55,6 +40,6 @@ Checkout our [guide](docs/GOOGLE_TAG_MANAGER.md) for info on setting up Google T

Checkout our [guide](docs/NOTIFICATIONS.md) for info on configuring notification icons and colors.

## API
## Documentation API

See the full [API](docs/API.md) available for this plugin.
See the full [documentation API](docs/index.md) available for this plugin.
87 changes: 87 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,25 @@ Stop the trace
window.FirebasePlugin.stopTrace("test trace");
```

## isPerformanceEnabled
Check if Firebase Performance Collection is enabled.

```
window.FirebasePlugin.isPerformanceEnabled(function(enabled){ console.log("Performace is %s", enabled ? "enabled" : "disabled" ) }, error);
```

## enabeldPerformance
Enabled Firebase Performance Collection.
```
window.FirebasePlugin.enabeldPerformance(success);
```

## setPerformanceCollectionEnabled
Enabled Firebase Performance Collection.
```
window.FirebasePlugin.setPerformanceCollectionEnabled(true, success, error);
```

## setAnalyticsCollectionEnabled

Enable/disable analytics collection
Expand All @@ -369,3 +388,71 @@ window.FirebasePlugin.setAnalyticsCollectionEnabled(true); // Enables analytics

window.FirebasePlugin.setAnalyticsCollectionEnabled(false); // Disables analytics collection
```

## Universal links & Deeplink
To support Firebase Dynamic Links it was necessary to manage Universal Links and Deeplinks. The implementation is inspired by the plugins [cordova-universal-links-plugin](https://github.com/nordnet/cordova-universal-links-plugin) and [cordova-plugin-customurlscheme](https://github.com/EddyVerbruggen/Custom-URL-scheme). When configured, the javascript function `handleOpenUrl` will be called after the app is started.

### Configuration iOS
- Enabled the capabilities *Associated Domains* and add the domains. Ex. `applinks:www.examplesite.com`
[Associated domains](associated_domains.png)
- Under Info tab add the *URL Types* for enabled custom url scheme.
[URL Types](url_types.png)

### Configuration Android
Edit AndroidManifest.xml:

- For Universal links:
```xml
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="www.examplesite.com" android:scheme="http" />
<data android:host="www.examplesite.com" android:scheme="https" />
</intent-filter>
```

- For Custom url
```xml
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="demoapp" />
</intent-filter>
```


### Usage:

```js
window.handleOpenURL = function handleOpenURL(url) {
setTimeout(function(url){
alert(url);
}, 0);
}
```

## Firebase Dynamic links
They are like the Universal links. The Dynamic Link will be processed by the Firebase library which will send the tracking information automatically. At the end the JS function `handleOpenUrl` will be called with url.

### Configuration iOS
Enabled the capabilities *Associated Domains* and add the domains. Ex. `applinks:demoapp.page.link`, is the subdomain created in the Firebase panel.
[Associated domains page link](associated_domains_page_link.png)

### Configuration Android
Edit AndroidManifest.xml:

```xml
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="demoapp.page.link" android:scheme="http" />
<data android:host="demoapp.page.link" android:scheme="https" />
</intent-filter>
```

## Enable debug view for Analytics and Dynamic Links

[Documentation Firebase](https://firebase.google.com/docs/analytics/debugview)
111 changes: 111 additions & 0 deletions docs/Analytics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Google Analytics for Firebase
Official link https://firebase.google.com/docs/analytics/


## logEvent

Log an event
```
window.FirebasePlugin.logEvent("select_content", {content_type: "page_view", item_id: "home"});
```

## setScreenName

Set the name of the current screen:
```
window.FirebasePlugin.setScreenName("Home");
```

## setUserId

Set a user id for use:
```
window.FirebasePlugin.setUserId("user_id");
```

## setUserProperty

Set a user property for use:
```
window.FirebasePlugin.setUserProperty("name", "value");
```

## setAnalyticsCollectionEnabled

Enable/disable analytics collection.

```
window.FirebasePlugin.setAnalyticsCollectionEnabled(true/false); // Enables or disabled analytics collection
```

<br>
# Disable Analytics Collection
### Permanently deactivate collection
For more information read the documentation https://firebase.google.com/support/guides/disable-analytics

#### Android
If you need to deactivate Analytics collection permanently in a version of your app, set *firebase_analytics_collection_deactivated* to true in your app's AndroidManifest.xml in the application tag. For example:

```xml
<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />
```

#### iOS
If you need to deactivate Analytics collection permanently in a version of your app, set *FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED* to YES in your app's Info.plist file. Setting *FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED* to YES takes priority over any values for FIREBASE_ANALYTICS_COLLECTION_ENABLED in your app's Info.plist as well as any values set with setAnalyticsCollectionEnabled.

To re-enable collection, remove *FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED* from your Info.plist. Setting *FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED* to NO has no effect and results in the same behavior as not having *FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED* set in your Info.plist file.

<br>
### Disable Advertising ID collection
#### Android
If you wish to disable collection of the Advertising ID in your Android app, you can set the value of *google_analytics_adid_collection_enabled* to false in your app's AndroidManifest.xml in the application tag. For example:

```xml
<meta-data android:name="google_analytics_adid_collection_enabled" android:value="false" />
```

### iOS
This feature does not exist.


<br>
# Debugging Events
For more information read the documentation https://firebase.google.com/docs/analytics/debugview

### Android
For Android, enable or disable debugging using the adb command

Enabled
```
adb shell setprop debug.firebase.analytics.app <package_name>
```

Disabled
```
adb shell setprop debug.firebase.analytics.app .none.
```

### iOS
To enable Analytics Debug mode on your development device, specify the following command line argument in Xcode:

1. In Xcode, select Product > Scheme > Edit scheme...
2. Select Run from the left menu.
3. Select the Arguments tab.
4. In the Arguments Passed On Launch section, add -FIRAnalyticsDebugEnabled.

Enabled
```
-FIRDebugEnabled
```

Disabled
```
-FIRDebugDisabled
```
You can also set this parameter using the Swift code, by inserting these lines in the *AppDelegate* file within the *didFinishLaunchingWithOptions* method.

```swift
var newArguments = ProcessInfo.processInfo.arguments
newArguments.append("-FIRDebugEnabled")
ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")
```
Loading