Skip to content

Commit

Permalink
doc: cleanup docs (havesource#51)
Browse files Browse the repository at this point in the history
* doc: cleanup docs
* doc: remove old minSdkVersion 14 common error
* doc: Update docs/INSTALLATION.md
* doc(android): remove compilation about old support library
* doc: update readme

Co-authored-by: jcesarmobile <[email protected]>
  • Loading branch information
erisu and jcesarmobile authored Oct 23, 2020
1 parent 3298b62 commit ea8ea28
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 121 deletions.
31 changes: 4 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,13 @@

> Register and receive push notifications
# Warning
# What is this?

The links below take you to the version 2.x documentation which includes a
number of breaking API changes from version 1.x, mostly the move from GCM to
FCM. If you are using version 1.x please reference the docs in the
[v1.x branch](https://github.com/phonegap/phonegap-plugin-push/tree/v1.x).
This plugin offers support to receive and handle native push notifications with a **single unified API**.

# What is this?
This does not mean you will be able to send a single push message and have it arrive on devices running different operating systems. By default Android uses FCM and iOS uses APNS and their payloads are significantly different. Even if you are using FCM for both Android and iOS there are differences in the payload required for the plugin to work correctly. For Android **always** put your push payload in the `data` section of the push notification. For more information on why that is the case read [Notification vs Data Payload](https://github.com/havesource/cordova-plugin-push/blob/master/docs/PAYLOAD.md#notification-vs-data-payloads). For iOS follow the regular [FCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref).

This plugin offers support to receive and handle native push notifications with
a **single unified API**.

This does not mean you will be able to send a single push message and have it
arrive on devices running different operating systems. By default Android uses
FCM and iOS uses APNS and their payloads are significantly different. Even if
you are using FCM for both Android and iOS there are differences in the payload
required for the plugin to work correctly. For Android **always** put your push
payload in the `data` section of the push notification. For more information on
why that is the case read
[Notification vs Data Payload](https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#notification-vs-data-payloads).
For iOS follow the regular
[FCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref).

This plugin does not provide a way to determine which platform you are running
on. The best way to do that is use the `device.platform` property provided by
[cordova-plugin-device](https://github.com/apache/cordova-plugin-device).

Starting with version `2.0.0`, this plugin will support `CocoaPods` installation
of the `Firebase Cloud Messaging` library. More details are available in the
[Installation](docs/INSTALLATION.md#cocoapods) documentation.
This plugin does not provide a way to determine which platform you are running on. The best way to do that is use the `device.platform` property provided by [cordova-plugin-device](https://github.com/apache/cordova-plugin-device).

* [Reporting Issues](docs/ISSUES.md)
* [Installation](docs/INSTALLATION.md)
Expand Down
106 changes: 14 additions & 92 deletions docs/INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
- [Installation](#installation)
- [Installation Requirements](#installation-requirements)
- [Android details](#android-details)
- [Compilation](#compilation)
- [Co-existing with Facebook Plugin](#co-existing-with-facebook-plugin)
- [Co-existing with plugins that use Firebase](#co-existing-with-plugins-that-use-firebase)
- [Common errors](#common-errors)
- [minSdkVersion === 14](#minsdkversion--14)
- [Multidex](#multidex)
- [More than one library with package name 'com.google.android.gms'](#more-than-one-library-with-package-name-comgoogleandroidgms)
- [Browser details](#browser-details)
- [Browser quirks](#browser-quirks)
- [Browser Support](#browser-support)
- [iOS details](#ios-details)
- [System & Cordova Requirements](#system--cordova-requirements)
Expand All @@ -26,56 +23,35 @@

| Plugin version | Cordova CLI | Cordova Android | Cordova iOS | CocoaPods |
| -------------- | ----------- | --------------- | ----------- | --------- |
| 2.2.0 | 7.1.0 | 7.1.0 | 4.5.0 | 1.1.1 |
| 2.1.2 | 7.1.0 | 6.3.0 | 4.5.0 | 1.1.1 |
| 2.1.0 | 7.1.0 | 6.3.0 | 4.4.0 | 1.1.1 |
| 2.0.0 | 7.0.0 | 6.2.1 | 4.4.0 | 1.1.1 |
| 1.9.0 | 6.4.0 | 6.0.0 | 4.3.0 | 1.1.1 |
| 1.8.0 | 3.6.3 | 4.0.0 | 4.1.0 | N/A |
| 1.0.0 | 9.0.0 | 8.0.0 | 5.1.1 | 1.8.0 |

To install from the command line:

```bash
phonegap plugin add phonegap-plugin-push
cordova plugin add @havesource/cordova-plugin-push
```

or

```bash
cordova plugin add phonegap-plugin-push
```

It is also possible to install via repo url directly ( unstable )

```bash
phonegap plugin add https://github.com/phonegap/phonegap-plugin-push
```
It is also possible to install via repo url directly (unstable)

or

```bash
cordova plugin add https://github.com/phonegap/phonegap-plugin-push
cordova plugin add github:havesource/cordova-plugin-push
```

As of version 2.0.0 the SENDER_ID parameter has been removed at install time. Instead you put your google-services.json (Android) and/or GoogleService-Info.plist in the root folder of your project and then add the following lines into your config.xml.

In the platform tag for Android add the following resource-file tag if you are using cordova-android 7.0 or greater:
To configure the `SENDER_ID`, place your `google-services.json` (Android) and/or `GoogleService-Info.plist` in the root folder of your project and then add the following lines into your config.xml.

```xml
<platform name="android">
<resource-file src="google-services.json" target="app/google-services.json" />
</platform>
```
In the `platform` tag for Android add the following `resource-file` tag if you are using `cordova-android` 8.0 or greater:

If you are using cordova-android 6.x or earlier, add the following resource-file tag:
E.g.

```xml
<platform name="android">
<resource-file src="google-services.json" target="google-services.json" />
<resource-file src="google-services.json" target="/app/google-services.json" />
</platform>
```

By default, on iOS, the plugin will register with APNS. If you want to use FCM on iOS, in the platform tag for iOS add the resource-file tag:
By default, on iOS, the plugin will register with APNS. If you want to use FCM on iOS, in the `platform` tag for iOS add the following `resource-file` tag:

```xml
<platform name="ios">
Expand All @@ -96,41 +72,19 @@ By default, on iOS, the plugin will register with APNS. If you want to use FCM o
> Note: You need to specify the SENDER_ID variable in your config.xml if you plan on installing/restoring plugins using the prepare method. The prepare method will skip installing the plugin otherwise.
```xml
<plugin name="phonegap-plugin-push" spec="2.0.0" />
<plugin name="@havesource/cordova-plugin-push" spec="1.0.0" />
```

## Android details

### Compilation

As of version 2.1.0 the plugin has been switched to using pinned version of Gradle libraries. You will need to ensure that you have installed the following items through the Android SDK Manager:

* Android Support Repository version 47+

![android support library](https://user-images.githubusercontent.com/353180/33042340-7ea60aaa-ce0f-11e7-99f7-4631e4c3d7be.png)

For more detailed instructions on how to install the Android Support Library visit [Google's documentation](https://developer.android.com/tools/support-library/setup.html).

_Note:_ if you are using an IDE to like Eclipse, Xamarin, etc. then the Android SDK installed by those tools may not be the same version as the one used by the Cordova/PhoneGap CLI while building. Please make sure your command line tooling is up to date with the software versions above. An easy way to make sure you up to date is to run the following command:

```bash
android update sdk --no-ui --filter "extra"
```

### Co-existing with Facebook Plugin

There are a number of Cordova Facebook Plugins available but the one that we recommend is [Jeduan's fork](https://github.com/jeduan/cordova-plugin-facebook4) of the original Wizcorp plugin. It is setup to use Gradle/Maven and the latest Facebook SDK properly.

To add to your app:

```bash
phonegap plugin add --save cordova-plugin-facebook4 --variable APP_ID="App ID" --variable APP_NAME="App Name"
```

or

```bash
cordova plugin add --save cordova-plugin-facebook4 --variable APP_ID="App ID" --variable APP_NAME="App Name"
cordova plugin add cordova-plugin-facebook4 --variable APP_ID="App ID" --variable APP_NAME="App Name"
```

### Co-existing with plugins that use Firebase
Expand All @@ -147,7 +101,7 @@ To make the two work together, you need to migrate your GCM project from Google
"cordova": {
"plugins": {
"havesource-cordova-plugin-push": {
"ANDROID_SUPPORT_V13_VERSION": "27.+",
"ANDROID_SUPPORT_V13_VERSION": "28.0.0",
"FCM_VERSION": "18.+"
}
},
Expand All @@ -162,34 +116,6 @@ _Note:_ The `FCM_VERSION` must be greater than or equal to 17.1.0 and less than

### Common errors

#### minSdkVersion === 14

If you have an issue compiling the app and you are getting an error similar to this:

```
* What went wrong:
Execution failed for task ':processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 15 declared in library .../platforms/android/build/intermediates/exploded-aar/com.facebook.android/facebook-android-sdk/4.6.0/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.facebook" to force usage
```

Then you can add the following entry into your config.xml file in the android platform tag:

```xml
<platform name="android">
<preference name="android-minSdkVersion" value="15"/>
</platform>
```

or compile your project using the following command, if the solution above doesn't work for you. Basically add `-- --minSdkVersion=15` to the end of the command line (mind the extra `--`, it's needed):

```bash
cordova compile android -- --minSdkVersion=15
cordova build android -- --minSdkVersion=15
cordova run android -- --minSdkVersion=15
cordova emulate android -- --minSdkVersion=15
```

#### Multidex

If you have an issue compiling the app and you're getting an error similar to this (`com.android.dex.DexException: Multiple dex files define`):
Expand Down Expand Up @@ -217,7 +143,7 @@ Common plugins to suffer from this outdated dependency management are plugins re

#### More than one library with package name 'com.google.android.gms'

When some other packages include `cordova-google-play-services` as a dependency, such as is the case with the cordova-admob and cordova-plugin-analytics plugins, it is impossible to also add the phonegap-plugin-push, for the following error will rise during the build process:
When some other packages include `cordova-google-play-services` as a dependency, such as is the case with the `cordova-admob` and `cordova-plugin-analytics` plugins, it is impossible to also add the `@havesource/cordova-plugin-push`, for the following error will rise during the build process:

```
:processDebugResources FAILED
Expand All @@ -237,11 +163,7 @@ Alternatively, switch to another plugin that provides the same functionality but

## Browser details

### Browser quirks

For the time being push support on the browser will only work using the PhoneGap push server.

When you run `phonegap serve` to test browser push point your browser at `http://localhost:3000`. The browser push implementation uses the W3C Push Spec's implementation which relies on ServiceWorkers and ServiceWorkers can only be accessed via the `https` protocol or via `http://localhost`. Pointing your browser at `localhost` will be the easiest way to test.
For the time being, push support on the browser is not supported. The original plugin used the PhoneGap push server which may no longer be active.

### Browser Support

Expand Down
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Type definitions for phonegap-plugin-push
// Project: https://github.com/phonegap/phonegap-plugin-push
// Project: https://github.com/havesource/cordova-plugin-push
// Definitions by: Frederico Galvão <https://github.com/fredgalvao>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

Expand Down Expand Up @@ -217,7 +217,7 @@ declare namespace PhonegapPluginPush {
clearBadge?: boolean | string
/**
* The data required in order to enable Action Buttons for iOS.
* Action Buttons on iOS - https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons-1
* Action Buttons on iOS - https://github.com/havesource/cordova-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons-1
*/
categories?: CategoryArray
/**
Expand Down

0 comments on commit ea8ea28

Please sign in to comment.