Commit bac11ebc authored by d4vidi's avatar d4vidi

Add various fixes

parent a34a79d9
......@@ -76,8 +76,8 @@ And the following methods to support registration and receiving notifications:
Add a reference to the library's native code in your global `settings.gradle`:
```
include ':reactnativenotifications'
project(':reactnativenotifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/android')
include ':react-native-notifications'
project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/android')
```
Declare the library as a dependency in your **app-project's** `build.gradle`:
......@@ -85,7 +85,8 @@ Declare the library as a dependency in your **app-project's** `build.gradle`:
```
dependencies {
// ...
compile project(':reactnativenotifications')
compile project(':react-native-notifications')
}
```
......@@ -95,13 +96,13 @@ dependencies {
Push notifications on Android are managed and dispatched using [Google's GCM service](https://developers.google.com/cloud-messaging/gcm) (now integrated into Firebase). The following installation steps are a TL;DR of [Google's GCM setup guide](https://developers.google.com/cloud-messaging/android/client). You can follow them to get GCM integrated quickly, but we recommend that you will in the very least have a peek at the guide's overview.
##### Step #1: Subscribe to Google's GCM
#### Step #1: Subscribe to Google's GCM
To set GCM in your app, you must first create a Google API-project and obtain a **Sender ID** and a **Server API Key**. If you have no existing API project yet, the easiest way to go about in creating one is using [this step-by-step installation process](https://developers.google.com/mobile/add); Use [this tutorial](https://code.tutsplus.com/tutorials/how-to-get-started-with-push-notifications-on-android--cms-25870) for insturctions.
Alternatively, follow [Google's complete guide](https://developers.google.com/cloud-messaging/android/client#create-an-api-project).
##### Step #2: Add Sender ID to Manifest File
#### Step #2: Add Sender ID to Manifest File
Once obtained, bundle the Sender ID onto your main `manifest.xml` file:
......@@ -118,6 +119,15 @@ Once obtained, bundle the Sender ID onto your main `manifest.xml` file:
```
#### Step #3: Add / verify GCM dependency in `build.gradle`:
```
dependencies {
// If you haven't already done so, add Google's GCM module:
compile "com.google.android.gms:play-services-gcm:9+"
}
```
---
......
......@@ -20,7 +20,7 @@ android {
dependencies {
// Google's GCM related framework components.
compile "com.google.android.gms:play-services-gcm:9+"
compile "com.google.android.gms:play-services-gcm:9.4.0"
compile 'com.facebook.react:react-native:+'
testCompile 'junit:junit:4.12'
......
......@@ -44,7 +44,7 @@ public class PushNotification implements IPushNotification {
protected PushNotification(Context context, Bundle bundle, AppLifecycleFacade appLifecycleFacade) {
mContext = context;
mAppLifecycleFacade = appLifecycleFacade;
mNotificationProps = new PushNotificationProps(bundle);
mNotificationProps = createProps(bundle);
}
public static IPushNotification get(Context context, Bundle bundle, AppLifecycleFacade facade) {
......@@ -97,6 +97,10 @@ public class PushNotification implements IPushNotification {
}
}
protected PushNotificationProps createProps(Bundle bundle) {
return new PushNotificationProps(bundle);
}
protected void setAsInitialNotification() {
InitialNotification.set(mNotificationProps);
}
......
......@@ -2,20 +2,21 @@ package com.wix.reactnativenotifications.core.notification;
import android.os.Bundle;
/**
* @author amitd
*/
public class PushNotificationProps {
private Bundle mBundle;
protected Bundle mBundle;
public PushNotificationProps(Bundle bundle) {
final String title = bundle.getString("title");
final String body = bundle.getString("body");
if (title == null || title.trim().isEmpty() || body == null || body.trim().isEmpty()) {
throw new IllegalArgumentException("Invalid notification");
}
public PushNotificationProps() {
mBundle = new Bundle();
}
public PushNotificationProps(String title, String body) {
mBundle = new Bundle();
mBundle.putString("title", title);
mBundle.putString("body", body);
}
public PushNotificationProps(Bundle bundle) {
mBundle = bundle;
}
......
package com.wix.reactnativenotifications.core.notificationdrawer;
import android.content.Context;
public interface INotificationsDrawerApplication {
IPushNotificationsDrawer getPushNotificationsDrawer();
IPushNotificationsDrawer getPushNotificationsDrawer(Context context);
}
......@@ -18,7 +18,7 @@ public class PushNotificationsDrawer implements IPushNotificationsDrawer {
public static IPushNotificationsDrawer get(Context context) {
final Context appContext = context.getApplicationContext();
if (appContext instanceof INotificationsDrawerApplication) {
return ((INotificationsDrawerApplication) appContext).getPushNotificationsDrawer();
return ((INotificationsDrawerApplication) appContext).getPushNotificationsDrawer(context);
}
return new PushNotificationsDrawer(context);
......
......@@ -32,7 +32,8 @@ dependencies {
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.facebook.react:react-native:+'
compile project(':reactnativenotifications')
compile "com.google.android.gms:play-services-gcm:9+"
compile project(':react-native-notifications')
testCompile 'junit:junit:4.12'
}
include ':myapplication'
include ':reactnativenotifications'
project(':reactnativenotifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/android')
include ':react-native-notifications'
project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/android')
......@@ -41,6 +41,10 @@ export class NotificationsAndroid {
notificationReceivedListener = null;
}
}
static refreshToken() {
RNNotifications.refreshToken();
}
}
export class PendingNotifications {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment