Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
Conflicts:
	unity-plugin/build.gradle
  • Loading branch information
Roman Savin committed Jul 10, 2015
2 parents 83350dc + 4d3b43a commit be2b6e0
Show file tree
Hide file tree
Showing 57 changed files with 2,173 additions and 491 deletions.
323 changes: 160 additions & 163 deletions .idea/inspectionProfiles/OPF.xml

Large diffs are not rendered by default.

35 changes: 23 additions & 12 deletions README.md
Expand Up @@ -14,6 +14,7 @@ provides possibility to use the system push provider for a specific device.
- [Download](#user-content-download)
- [How To Use](#user-content-how-to-use)
- [Using of OPFPushReceiver](#user-content-using-of-opfpushreceiver)
- [Notification payload support](#user-content-notification-payload-support)
- [Implemented Push Services](#user-content-implemented-push-services)
- [Create Custom Push Provider](#user-content-create-custom-push-provider)
- [Comparison of most popular push services](#user-content-comparison-of-most-popular-push-services)
Expand All @@ -28,7 +29,7 @@ provides possibility to use the system push provider for a specific device.
Download [the latest AAR][opfpush-latest-aar] of OPFPush and [the latest JAR][opfutils-latest-jar] of OPFUtils
or grab it via Gradle:
```groovy
compile 'org.onepf:opfpush:0.2.3@aar'
compile 'org.onepf:opfpush:0.3.0@aar'
compile 'org.onepf:opfutils:0.1.22'
```

Expand All @@ -37,7 +38,7 @@ provides possibility to use the system push provider for a specific device.
<dependency>
<groupId>org.onepf</groupId>
<artifactId>opfpush</artifactId>
<version>0.2.3</version>
<version>0.3.0</version>
<type>aar</type>
</dependency>
<dependency>
Expand Down Expand Up @@ -95,20 +96,26 @@ to implement GCM using OPFPush library.
You can use `BroadcastReceiver` instead of `EventListener` for receiving push events.
See [the following section][opfpush-receiver-section]

##Notification payload support

[GCM Notification payload support][gcm-notification-payload-support] was added to the library.
Also we have implemented a similar mechanism for all supported push providers.
See [the following section][opf-notification-payload-support]

## Implemented Push Services

1. [Google Cloud Messaging][google-cloud-messaging].
Download [the latest AAR][gcm-latest-aar] or grab via Gradle:
```groovy
compile 'org.onepf:opfpush-gcm:0.2.3@aar'
compile 'org.onepf:opfpush-gcm:0.3.0@aar'
```

or Maven:
```xml
<dependency>
<groupId>org.onepf</groupId>
<artifactId>opfpush-gcm</artifactId>
<version>0.2.3</version>
<version>0.3.0</version>
<type>aar</type>
</dependency>
```
Expand All @@ -118,15 +125,15 @@ See [the following section][opfpush-receiver-section]
2. [Amazon Device Messaging][amazon-device-messaging].
Download [the latest AAR][adm-latest-aar] or grab via Gradle:
```groovy
compile 'org.onepf:opfpush-adm:0.2.3@aar'
compile 'org.onepf:opfpush-adm:0.3.0@aar'
```

or Maven:
```xml
<dependency>
<groupId>org.onepf</groupId>
<artifactId>opfpush-adm</artifactId>
<version>0.2.3</version>
<version>0.3.0</version>
<type>aar</type>
</dependency>
```
Expand All @@ -136,15 +143,15 @@ See [the following section][opfpush-receiver-section]
3. [Nokia Notifications][nokia-notifications].
Download [the latest AAR][nokia-latest-aar] or grab via Gradle:
```groovy
compile 'org.onepf:opfpush-nokia:0.2.3@aar'
compile 'org.onepf:opfpush-nokia:0.3.0@aar'
```
or Maven:
```xml
<dependency>
<groupId>org.onepf</groupId>
<artifactId>opfpush-nokia</artifactId>
<version>0.2.3</version>
<version>0.3.0</version>
<type>aar</type>
</dependency>
```
Expand All @@ -160,6 +167,8 @@ To create a custom push provider see [the following section][custom-push-provide
| Criteria | GCM | ADM | Nokia Notifications | OPFPush |
| :---------------------------------- | :---: | :---: | :-----------------: | :---------: |
| Receive messages | + | + | + | + |
| Multiple senders | + | - | + | + |
| Notification payload support | + | - | - | - |
| Asynchronous registration and unregistration | - | + | + | + |
| Retry register on fail | - | + | + | + |
| Retry register on fail after reboot | - | - | - | + |
Expand Down Expand Up @@ -202,9 +211,11 @@ Take a look at the usage of the OPFPush library in our [sample application][samp
[opfpush-gcm]: ./opfpush-providers/gcm
[opfpush-adm]: ./opfpush-providers/adm
[opfpush-nokia]: ./opfpush-providers/nokia
[opfpush-latest-aar]: https://github.com/onepf/OPFPush/releases/download/v0.2.3/opfpush-0.2.3.aar
[gcm-latest-aar]: https://github.com/onepf/OPFPush/releases/download/v0.2.3/opfpush-gcm-0.2.3.aar
[adm-latest-aar]: https://github.com/onepf/OPFPush/releases/download/v0.2.3/opfpush-adm-0.2.3.aar
[nokia-latest-aar]: https://github.com/onepf/OPFPush/releases/download/v0.2.3/opfpush-nokia-0.2.3.aar
[gcm-notification-payload-support]: https://developers.google.com/cloud-messaging/server-ref#notification-payload-support
[opf-notification-payload-support]: https://github.com/onepf/OPFPush/wiki/Notification-payload-support
[opfpush-latest-aar]: https://github.com/onepf/OPFPush/releases/download/v0.3.0/opfpush-0.3.0.aar
[gcm-latest-aar]: https://github.com/onepf/OPFPush/releases/download/v0.3.0/opfpush-gcm-0.3.0.aar
[adm-latest-aar]: https://github.com/onepf/OPFPush/releases/download/v0.3.0/opfpush-adm-0.3.0.aar
[nokia-latest-aar]: https://github.com/onepf/OPFPush/releases/download/v0.3.0/opfpush-nokia-0.3.0.aar
[easiest-gcm]: https://github.com/onepf/OPFPush/wiki/The-easiest-way-to-implement-GCM
[sample]: https://github.com/onepf/OPFPush/tree/master/samples/pushchat
12 changes: 6 additions & 6 deletions opfpush-providers/adm/README.md
Expand Up @@ -19,31 +19,31 @@ allprojects {

Download [the latest AAR][adm-latest-aar] or grab via Gradle:
```groovy
compile 'org.onepf:opfpush-adm:0.2.3@aar'
compile 'org.onepf:opfpush-adm:0.3.0@aar'
```

or Maven:
```xml
<dependency>
<groupId>org.onepf</groupId>
<artifactId>opfpush-adm</artifactId>
<version>0.2.3</version>
<version>0.3.0</version>
<type>aar</type>
</dependency>
```

You can also use JAR dependency.
Download [the latest JAR][adm-latest-jar] or grab via Gradle:
```groovy
compile 'org.onepf:opfpush-adm:0.2.3'
compile 'org.onepf:opfpush-adm:0.3.0'
```

or Maven:
```xml
<dependency>
<groupId>org.onepf</groupId>
<artifactId>opfpush-adm</artifactId>
<version>0.2.3</version>
<version>0.3.0</version>
</dependency>
```

Expand Down Expand Up @@ -127,5 +127,5 @@ builder.addProviders(new ADMProvider(context));
```

[1]: https://developer.amazon.com/appsandservices/apis/engage/device-messaging
[adm-latest-aar]: https://github.com/onepf/OPFPush/releases/download/v0.2.3/opfpush-adm-0.2.3.aar
[adm-latest-jar]: https://github.com/onepf/OPFPush/releases/download/v0.2.3/opfpush-adm-0.2.3.jar
[adm-latest-aar]: https://github.com/onepf/OPFPush/releases/download/v0.3.0/opfpush-adm-0.3.0.aar
[adm-latest-jar]: https://github.com/onepf/OPFPush/releases/download/v0.3.0/opfpush-adm-0.3.0.jar
6 changes: 4 additions & 2 deletions opfpush-providers/adm/build.gradle
Expand Up @@ -21,17 +21,19 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionName "0.2.3"
versionName "0.3.0"
}
}

dependencies {
testCompile 'junit:junit:4.12'
//noinspection NewerVersionAvailable
testCompile 'org.robolectric:robolectric:2.4'
androidTestCompile 'junit:junit:4.12'
//noinspection NewerVersionAvailable
androidTestCompile 'org.robolectric:robolectric:2.4'

compile 'org.onepf:opfpush:0.2.3@aar'
compile 'org.onepf:opfpush:0.3.0@aar'

provided 'com.amazon:amazon-device-messaging:1.0.1'
provided 'com.android.support:support-annotations:19.1.0'
Expand Down
Expand Up @@ -23,6 +23,7 @@

import org.onepf.opfpush.listener.CheckManifestHandler;
import org.onepf.opfpush.model.AvailabilityResult;
import org.onepf.opfpush.notification.NotificationMaker;
import org.onepf.opfpush.pushprovider.PushProvider;
import org.onepf.opfutils.OPFLog;

Expand Down Expand Up @@ -51,6 +52,17 @@ public ADMProvider(@NonNull final Context context) {
}
}

public ADMProvider(@NonNull final Context context,
@NonNull final NotificationMaker notificationMaker) {
if (Build.MANUFACTURER.equals(AMAZON_MANUFACTURER)) {
OPFLog.d("It's an Amazon device.");
provider = new ADMProviderImpl(context.getApplicationContext(), notificationMaker);
} else {
OPFLog.d("It's no an Amazon device.");
provider = new ADMProviderStub();
}
}

@Override
public void register() {
provider.register();
Expand Down Expand Up @@ -90,6 +102,12 @@ public String getHostAppPackage() {
return provider.getHostAppPackage();
}

@NonNull
@Override
public NotificationMaker getNotificationMaker() {
return provider.getNotificationMaker();
}

@Override
public void checkManifest(@Nullable final CheckManifestHandler checkManifestHandler) {
provider.checkManifest(checkManifestHandler);
Expand Down
Expand Up @@ -31,6 +31,7 @@
import org.onepf.opfpush.BasePushProvider;
import org.onepf.opfpush.listener.CheckManifestHandler;
import org.onepf.opfpush.model.AvailabilityResult;
import org.onepf.opfpush.notification.NotificationMaker;
import org.onepf.opfpush.utils.CheckUtils;
import org.onepf.opfutils.OPFLog;

Expand All @@ -52,15 +53,17 @@
class ADMProviderImpl extends BasePushProvider {

@NonNull
private final ADM adm;
private final ADM adm = new ADM(getContext().getApplicationContext());

@NonNull
private final PreferencesProvider preferencesProvider;
private final PreferencesProvider preferencesProvider = PreferencesProvider.getInstance(getContext());

public ADMProviderImpl(@NonNull final Context context) {
super(context, PROVIDER_NAME, KINDLE_STORE_APP_PACKAGE);
adm = new ADM(context.getApplicationContext());
preferencesProvider = PreferencesProvider.getInstance(getContext());
}

public ADMProviderImpl(@NonNull final Context context, @NonNull final NotificationMaker notificationMaker) {
super(context, PROVIDER_NAME, KINDLE_STORE_APP_PACKAGE, notificationMaker);
}

@Override
Expand Down
Expand Up @@ -16,11 +16,13 @@

package org.onepf.opfpush.adm;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import org.onepf.opfpush.listener.CheckManifestHandler;
import org.onepf.opfpush.model.AvailabilityResult;
import org.onepf.opfpush.notification.NotificationMaker;
import org.onepf.opfpush.pushprovider.PushProvider;
import org.onepf.opfutils.OPFLog;

Expand Down Expand Up @@ -78,6 +80,23 @@ public String getHostAppPackage() {
return null;
}

@NonNull
@Override
public NotificationMaker getNotificationMaker() {
OPFLog.logMethod();
return new NotificationMaker() {
@Override
public boolean needShowNotification(@NonNull Bundle bundle) {
return false;
}

@Override
public void showNotification(@NonNull Context context, @NonNull Bundle bundle) {
//nothing
}
};
}

@Override
public void checkManifest(@Nullable final CheckManifestHandler checkManifestHandler) {
OPFLog.logMethod();
Expand Down
41 changes: 24 additions & 17 deletions opfpush-providers/gcm/README.md
Expand Up @@ -4,31 +4,31 @@

Download [the latest AAR][gcm-latest-aar] or grab via Gradle:
```groovy
compile 'org.onepf:opfpush-gcm:0.2.3@aar'
compile 'org.onepf:opfpush-gcm:0.3.0@aar'
```

or Maven:
```xml
<dependency>
<groupId>org.onepf</groupId>
<artifactId>opfpush-gcm</artifactId>
<version>0.2.3</version>
<version>0.3.0</version>
<type>aar</type>
</dependency>
```

You can also use JAR dependency.
Download [the latest JAR][gcm-latest-jar] or grab via Gradle:
```groovy
compile 'org.onepf:opfpush-gcm:0.2.3'
compile 'org.onepf:opfpush-gcm:0.3.0'
```

or Maven:
```xml
<dependency>
<groupId>org.onepf</groupId>
<artifactId>opfpush-gcm</artifactId>
<version>0.2.3</version>
<version>0.3.0</version>
</dependency>
```

Expand All @@ -49,16 +49,13 @@ also add the following receiver:

```xml
<receiver
android:name="org.onepf.opfpush.gcm.GCMReceiver"
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="${applicationId}" />
</intent-filter>
<intent-filter>
<action android:name="org.onepf.opfpush.gcm.intent.UNREGISTRATION" />
<action android:name="org.onepf.opfpush.gcm.intent.REGISTRATION" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="${applicationId}"/>
</intent-filter>
</receiver>
```
Expand All @@ -67,17 +64,27 @@ If you use JAR dependency, you also must add to your application AndroidManifest

```xml
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />

<application>
<service
android:name="org.onepf.opfpush.gcm.GCMService"
android:exported="false" />
android:name=".GCMService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>

<service
android:name=".GCMInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>

<service
android:name="org.onepf.opfpush.gcm.SendMessageService"
android:exported="false" />

</application>
```

Expand All @@ -91,5 +98,5 @@ builder.addProviders(new GCMProvider(context, GCM_SENDER_ID));
```

[1]: https://developer.android.com/google/gcm/index.html
[gcm-latest-aar]: https://github.com/onepf/OPFPush/releases/download/v0.2.3/opfpush-gcm-0.2.3.aar
[gcm-latest-jar]: https://github.com/onepf/OPFPush/releases/download/v0.2.3/opfpush-gcm-0.2.3.jar
[gcm-latest-aar]: https://github.com/onepf/OPFPush/releases/download/v0.3.0/opfpush-gcm-0.3.0.aar
[gcm-latest-jar]: https://github.com/onepf/OPFPush/releases/download/v0.3.0/opfpush-gcm-0.3.0.jar

0 comments on commit be2b6e0

Please sign in to comment.