Skip to content

Commit

Permalink
New vision for the installation of the plugin. Library dependencies a…
Browse files Browse the repository at this point in the history
…re decided by the developer and not by the plugin. This is to improve the update of dependency libraries. In addition, some unpicked pull requests were included, due to the need for development. Improved Firebase Crashlitycs, adding non-fatal carsh tracking. Rewrite the documentation based on the official Firebase documentation.
  • Loading branch information
vash15 committed Mar 8, 2019
1 parent ba72d8c commit 61e216c
Show file tree
Hide file tree
Showing 204 changed files with 1,286 additions and 28,572 deletions.
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.
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")
```
125 changes: 125 additions & 0 deletions docs/CloudMessaging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Firebase Cloud Messaging
Official link https://firebase.google.com/docs/cloud-messaging

## getToken

Get the device token (id):
```js
window.FirebasePlugin.getToken(function(token) {
// save this server-side and use it to push notifications to this device
console.log(token);
}, function(error) {
console.error(error);
});
```
Note that token will be null if it has not been established yet

## onTokenRefresh

Register for token changes:
```js
window.FirebasePlugin.onTokenRefresh(function(token) {
// save this server-side and use it to push notifications to this device
console.log(token);
}, function(error) {
console.error(error);
});
```
This is the best way to get a valid token for the device as soon as the token is established

## onNotificationOpen

Register notification callback:

```js
window.FirebasePlugin.onNotificationOpen(function(notification) {
console.log(notification);
}, function(error) {
console.error(error);
});
```
Notification flow:

1. App is in foreground:
1. User receives the notification data in the JavaScript callback without any notification on the device itself (this is the normal behaviour of push notifications, it is up to you, the developer, to notify the user)
2. App is in background:
1. User receives the notification message in its device notification bar
2. User taps the notification and the app opens
3. User receives the notification data in the JavaScript callback

Notification icon on Android:

[Changing notification icon](NOTIFICATIONS.md#changing-notification-icon)

## grantPermission (iOS only)

Grant permission to receive push notifications (will trigger prompt):

```js
window.FirebasePlugin.grantPermission();
```
## hasPermission

Check permission to receive push notifications:

```js
window.FirebasePlugin.hasPermission(function(data){
console.log(data.isEnabled);
});
```

## setBadgeNumber

Set a number on the icon badge:

```js
window.FirebasePlugin.setBadgeNumber(3);
```

Set 0 to clear the badge

```js
window.FirebasePlugin.setBadgeNumber(0);
```

## getBadgeNumber

Get icon badge number:

```js
window.FirebasePlugin.getBadgeNumber(function(n) {
console.log(n);
});
```

## clearAllNotifications

Clear all pending notifications from the drawer:

```js
window.FirebasePlugin.clearAllNotifications();
```

## subscribe

Subscribe to a topic:

```js
window.FirebasePlugin.subscribe("example");
```

## unsubscribe

Unsubscribe from a topic:

```js
window.FirebasePlugin.unsubscribe("example");
```

## unregister

Unregister from firebase, used to stop receiving push notifications. Call this when you logout user from your app. :

```js
window.FirebasePlugin.unregister();
```
Loading

0 comments on commit 61e216c

Please sign in to comment.