Giter Club home page Giter Club logo

react-native-system-notification's Introduction

[WARNING: NOT MAINTAINED] Android system notifications for React Native. Supports push notifications with GCM integrated. Another push-notification solution on Android is https://github.com/zo0r/react-native-push-notification, it features on providing the same API on iOS and Android, while this one supports more notification features on Android.

react-native-system-notification npm version

Send or schedule Android system notifications for React Native.

Table of Contents


import React, { DeviceEventEmitter } from 'react-native';
import Notification from 'react-native-system-notification';

// Send a simple notification
Notification.create({ subject: 'Hey', message: 'Yo! Hello world.' });

// Listen to notification-clicking events
Notification.addListener('press', function(e) {
  console.log(e);
});

// Custom payload for notifications
Notification.create({
  subject: 'Notification With Payload',
  message: 'This is a notification that contains custom payload.',
  payload: { number: 1, what: true, someAnswer: '42' }
});

// Receive the payload on notification events
Notification.addListener('press', function(e) {
  console.log(e.payload);  // => { number: 1, what: true, someAnswer: '42' }
});

// Customize notification
Notification.create({
  subject: 'Notification With Custom Icon',
  message: 'This is a notification with a specified icon.',
  smallIcon: 'ic_alert'
});

// Scheduled notifications
Notification.create({
  subject: 'Scheduled Notification',
  message: 'This notification will show on every Friday morning at 8:30 AM, starts at 2015/9/9 and end after 10 times.',
  sendAt: new Date(2015, 9, 9, 8, 30),
  repeatEvery: 'week',
  count: 10
});

Installation

  • Run npm install react-native-system-notification --save to install using npm.

  • Add the following two lines to android/settings.gradle:

include ':react-native-system-notification'
project(':react-native-system-notification').projectDir = new File(settingsDir, '../node_modules/react-native-system-notification/android')
  • Edit android/app/build.gradle and add the annoated lines as below:
...

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:0.16.+"
    compile project(':react-native-system-notification')  // <- Add this line
}
  • Edit android/app/src/main/AndroidManifest.xml and add the annoated lines as below:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.reactnativeproject">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_TASKS" />                       <!-- <- Add this line -->
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>           <!-- <- Add this line -->
    <uses-permission android:name="android.permission.VIBRATE"/>                          <!-- <- Add this line -->

    <application
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme">

...

      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
      <receiver android:name="io.neson.react.notification.NotificationEventReceiver" />   <!-- <- Add this line -->
      <receiver android:name="io.neson.react.notification.NotificationPublisher" />       <!-- <- Add this line -->
      <receiver android:name="io.neson.react.notification.SystemBootEventReceiver">       <!-- <- Add this line -->
        <intent-filter>                                                                   <!-- <- Add this line -->
          <action android:name="android.intent.action.BOOT_COMPLETED"></action>           <!-- <- Add this line -->
        </intent-filter>                                                                  <!-- <- Add this line -->
      </receiver>                                                                         <!-- <- Add this line -->
    </application>

</manifest>

The RECEIVE_BOOT_COMPLETED permission is used to re-register all scheduled notifications after reboot. Requesting VIBRATE permission is required if you want to make the device vibrate while sending notifications.

  • Edit MainActivity.java (usually at android/app/src/main/java/com/<project-name>/MainActivity.java) and add the annoated lines as below:
...

import android.content.Intent;
import android.os.Bundle;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;

import io.neson.react.notification.NotificationPackage;    // <- Add this line

public class MainApplication extends Application implements ReactApplication {

...

    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            ...
            new NotificationPackage()                  // <- Add this line
        );
    }

...

Usage

Creating Notifications

Just do:

Notification.create({
  id: 1337,
  subject: 'Notification With Payload',
  message: 'This is a notification that contains custom payload.',
  smallIcon: 'ic_launcher',
  autoClear: true,
  payload: { number: 1, what: true, someAnswer: '42' }
});

All functions of this module will return promises with the notification object handing in. So you can get the data of the notification and do anything that is needed, like this:

Notification.create({ message: 'Testing.' }).then(function(notification) {
  console.log(notification);
  console.log(notification.id);
});

All available options on a notification are listed below:

Basic

id (number) The unique ID of this notification. It will be randomly chosen if not specified.

subject (string) The notification subject. Defaults to the application name on Android.

message (string) The message showen in the notification.

action (string) An action name that can be used to determine what to do when this notification is clicked. Defaults to DEFAULT.

payload (object) A custom payload object. It can be retrieved on events of this notification. Defaults to {}.

Scheduling

delay (number) Milliseconds to delay before showing this notification after it is created. Useful when creating countdown alarms, reminders, etc. Note that it cannot be used with sendAt.

sendAt (Date) Schedule this notification to show on a specified time. Note that it cannot be used with delay.

repeatEvery (string or number) Must use with sendAt. Schedule this notification to repeat. Can be minute, hour, halfDay, day, week, month, year or a number of time in milliseconds.

repeatCount (number) Must use with sendAt and repeatEvery. End repeating this notification after n times. Note that it cannot be used with endAt.

endAt (Date) Must use with sendAt and repeatEvery. End repeating this notification after a specified time. Note that it cannot be used with repeatCount.

Some Samples of Scheduled Notifications

Notification.create({
  subject: 'Scheduled Notification',
  message: 'This notification will show on every Friday morning at 8:30 AM, starts at 2015/9/9 and end after 10 times.',
  sendAt: new Date(2015, 9, 9, 8, 30),
  repeatEvery: 'week',
  repeatCount: 10
});
Notification.create({
  subject: 'Scheduled Notification',
  message: 'This notification will show on 2015/9/9 morning at 8:30 AM, and repeat for 10 times every minute.',
  sendAt: new Date(2015, 9, 9, 8, 30),
  repeatEvery: 60000,
  repeatCount: 10
});
Notification.create({
  subject: 'Delayed Notification',
  message: 'This notification will show after 10 seconds, even the app has been stoped.',
  delay: 10000
});

Customization

priority (number) Priority of this notification, can be -2, -1, 0, 1, 2. When this is set to 1 or 2, heads-up notification will be more likely to show on Android 5+. Defaults to 1.

smallIcon (string) The icon (file name) to show. This icon must be placed in the project's android/app/src/main/res/mipmap-* folder. Defaults to ic_launcher.

largeIcon (string) Not yet implemented.

sound (string) Set the sound to play. Defaults to default as using the default notification sound, or set this to null to disable the sound. Other options are not yet implemented.

vibrate (string) Set the vibration pattern to use. Defaults to default as using the default notification vibrate, or set this to null to disable the vibrate. Other options are not yet implemented.

lights (string) Set the desired color for the indicator LED on the device. Defaults to default as using the default notification lights, or set this to null to disable the lights. Other options are not yet implemented.

autoClear (boolean) Clear this notification automatically after the user clicks on it. Defaults to true.

onlyAlertOnce (boolean) Do not let the sound, vibrate and ticker to be played if the notification is already showing.

tickerText (string) Set the text to show on ticker. Defaults to <subject>: <message>. Set this to null to disable ticker.

when (Date) Add a timestamp pertaining to the notification (usually the time the event occurred).

bigText (string) Set the text to be shown when the user expand the notification.

bigStyleImageBase64 (string) Set the image in base64 to be shown when the user expand the notification. if bigText is not null, it have priority over bigStyleImageBase64.

bigStyleUrlImgage (string)
Set URL of a image. Geting it by open a stream connection and it be shown when the user expand the notification.. if bigText is not null, it have priority over bigStyleUrlImgage

subText (string) Set the third line of text in the platform notification template. Note that it cannot be used with progress.

progress (number) Set the progress this notification represents, range: 0.0 ~ 1.0. Set this to a number lower then zero to get an indeterminate progress. Note that it cannot be used with subText.

color (string) Color to be applied by the standard Style templates when presenting this notification.

number (number) Set a number on the notification.

private (boolean) Not yet implemented.

ongoing (boolean) Not yet implemented.

category (string) Set the notification category, e.g.: alarm, call, email, event, progress, reminder, social. It may be used by the Android system for ranking and filtering.

localOnly (boolean) Set whether or not this notification should not bridge to other devices.

Handle Notification Click Event

Register a listener on sysNotificationClick events to handle notification clicking:

Notification.addListener('press', function(e) {
  console.log(e);
});

The action and payload of the notification can be retrieved on these events:

Notification.send({ message: 'Message', action: 'ACTION_NAME', payload: { data: 'Anything' } });
Notification.addListener('press', function(e) {
  switch (e.action) {
    case 'ACTION_NAME':
      console.log(`Action Triggered! Data: ${e.payload.data}`);
      break;

    case 'ANOTHER_ACTION_NAME':
      console.log(`Another Action Triggered! Data: ${e.payload.data}`);
      break;
  }
});

Once you no longer need to listen to sysNotificationClick events de-register the listener functions with:

Notification.removeAllListeners('press');

Manage Scheduled Notifications

Sometimes you'll need to get the scheduled notifications (which has delay or sendAt set up) that you had created before. You can use Notification.getIDs() to retrieve an array of IDs of available (i.e. will be send in the future) scheduled notifications.

Notification.getIDs().then(function(ids) {
  console.log(ids);  // Array of ids
});

and use Notification.find(notificationID) to get data of an notification.

Notification.find(notificationID).then(function(notification) {
  console.log(notification);
});

or just cancel it with Notification.delete(notificationID):

Notification.delete(notificationID);

Want to cancel all scheduled notifications set by your app? Sure:

Notification.deleteAll();

To update a scheduled notification, just use Notification.create() with the same id.

Clearing Notifications

When you want to clear a notification from the system statusbar, just use:

Notification.clearAll();

or:

Notification.clear(notificationID);

Push Notifications On Android

Sending push notification via web servers to Android is also easy! With react-native-gcm-android intergrated, you can just pass notification arguments through GCM (with the same format as JavaScript), your app will show it directly or put it into schedule. To set this up, follow these directions:

  1. Run npm install react-native-gcm-android --save to add react-native-gcm-android to your app

  2. Setup GCM, follow react-native-gcm-android's README to get GCM working.

  3. Open android/app/src/main/AndroidManifest.xml, change com.oney.gcm.RNGcmListenerService to io.neson.react.notification.GCMNotificationListenerService.

Then you can send push notifications like this, putting an notification object (just as the same thing that you use in JavaScript Notification.create()) into the GCM data (curl example):

curl -X POST -H "Authorization: key=<your_google_api_key>" -H "Content-Type: application/json" -d '
{
  "data": {
    "notification": {
      "subject": "Hello GCM",
      "message": "Hello from the server side!"
    }
  },
  "to" : "<device_token>"
}' 'https://gcm-http.googleapis.com/gcm/send'

The notification will be created natively (so this works even if the app is closed) when the device received the GCM message.

react-native-system-notification's People

Contributors

7kfpun avatar andy9775 avatar ianlin avatar jejan avatar lukefanning avatar reneviering avatar richarddewit avatar sichacvah avatar techrah avatar varungupta85 avatar zetavg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-native-system-notification's Issues

iOS Support

Are there plans to support the push request protocol for iOS (notification key inside of a data-only notification)?

how does the app reload when notification is pressed

I try to use the press event to navigate to another page according to the notification but the app seems to always load the same main page no matter how I try to change it
any help would be invaluable,
thanks

Ensure the App is ready in a more reasonable way when the notification is clicked

Because event handling is done by JS, we'll need to wait for React Native to be fully loaded before sending the click event.

Currently I use SystemClock.sleep(3000);, waiting for 3 seconds to for this, but there must be a more effective way to do this.

https://github.com/Neson/react-native-system-notification/blob/94ccaed7bc1c6edc7db0d251760c92c93cba5461/android/src/main/java/io/neson/react-native/notification/NotificationEventReceiver.java#L43

Possible Unhandled Promise Rejection

Hey,

I'm just going to integrate react-native-system-notification.

If i run Notification.create({ subject: 'Hey', message: 'Yo! Hello world.' });, no notification is shown. Instead i get this warning:

Possible Unhandled Promise Rejection (id: 0): Cannot read property 'rGetApplicationName' of undefined TypeError: Cannot read property 'rGetApplicationName' of undefined at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:71431:19 at tryCallTwo (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:10869:1) at doResolve (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:11024:9) at new Promise (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:10890:1) at Object.Notification.create (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:71430:8) at Object.addSurgeryDate (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:67712:41) at ProxyComponent._reactNative4.default.createClass.acceptChoosenDate (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:71797:26) at ProxyComponent.proxiedMethod [as acceptChoosenDate] (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:4872:22) at ProxyComponent.React.createClass.touchableHandlePress (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:52152:32) at ProxyComponent.proxiedMethod [as touchableHandlePress] (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:4872:22)

Do you have any idea on that? I performed the setup as described.

Sound / vibration

Neither sound nor vibration seems to be working at the moment.

Is the documentation not up to date?

Play a custom sound for notification

I want to play a custom sound for a local notification. What do I need to put in the sound field? I tried the following:

Notification.create({
    subject: 'Scheduled Notification',
    message: 'Alarm triggered',
    sendAt: new Date(alarmDate),
    sound: 'alarm_1.m4a'
});

where alarm_1.m4a is an audio file that is present at <PROJECT-DIR>/android/app/src/main/res/raw/alarm_1.m4a but it still plays the default notification sound.

smallIcon problem

Hi, is there any limitation/format for small icons? I'm trying to display my own, but I can only seem to get the default info icon.

Clicking on scheduled notification restarts the app instead of opening from background

Whenever I click on a scheduled notification, my app completely restarts instead of waking up from the background, even though it's still running in the background.

Is this expected behaviour? On iOS my app is able to come back from the background after clicking a notification..

I'm testing with:

  • react-native 0.30.0
  • react-native-system-notification 0.2.0
  • Android 5.1.1

Lights not working

As I understand the default is to display a light when a notification comes in. However, I'm not getting them. I'm on "react-native": "^0.24.1" and Android 5.1.1.

I can't disable vibrations

Hello,

I tried to disable vibrations on notification, but it seems impossible.
Even if I set vibrate: null or remove <uses-permission android:name="android.permission.VIBRATE" />

I use a OnePlus One with android 5.1 and a Nexus 5 with Android 6

Error in BackgroundService

/home.../node_modules/react-native-gcm-android/android/src/main/java/com/oney/gcm/BackgroundService.java:34: error: constructor NotificationPackage in class NotificationPackage cannot be applied to given types;
                .addPackage(new NotificationPackage(null))
                            ^
  required: no arguments
  found: <null>
  reason: actual and formal argument lists differ in length
1 error
:RNGcmAndroid:compileReleaseJavaWithJavac FAILED

GCM Dependency Conflict!

Hi,

Your package requires play-services-gcm:8.1 and the rn gcm package requires the 8.3 version.
There should be a different solution than adding the gcm package as a peer.

Thank You!

com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzlv$zza

My builds are failing, anyone seen this before? NodeJS 4, ReactNative 0.26, on Mac OS X.

app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
:app:bundleDebugJsAndAssets SKIPPED
:app:processDebugManifest
:app:processDebugResources
Unknown source file : warning: string 'catalyst_debugjs' has no default translation.
Unknown source file : warning: string 'catalyst_element_inspector' has no default translation.
Unknown source file : warning: string 'catalyst_jsload_error' has no default translation.
Unknown source file : warning: string 'catalyst_jsload_message' has no default translation.
Unknown source file : warning: string 'catalyst_jsload_title' has no default translation.
Unknown source file : warning: string 'catalyst_reloadjs' has no default translation.
Unknown source file : warning: string 'catalyst_settings' has no default translation.
Unknown source file : warning: string 'catalyst_settings_title' has no default translation.

:app:generateDebugSources
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:preDexDebug UP-TO-DATE
:app:dexDebug
Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:
Unknown source file : com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzlv$zza;
Unknown source file : at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
Unknown source file : at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
Unknown source file : at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
Unknown source file : at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Unknown source file : at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
Unknown source file : at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
Unknown source file : at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
Unknown source file : at com.android.dx.command.dexer.Main.run(Main.java:277)
Unknown source file : at com.android.dx.command.dexer.Main.main(Main.java:245)
Unknown source file : at com.android.dx.command.Main.main(Main.java:106)

Initial action and payload on addListener

@neson It seems to be the case that after creating a notification with an action and payload while the app is in the background, the notification listener function is repeatedly being invoked on calling addListener.

The first time you do want that behaviour as it has come from the notification that was just pressed/clicked. However on returning to that screen within the app it then calls the listener function again. I am calling addListener in componentWillMount() on a particular screen.

Looking at your code it is clear that this is happening because this.module.sysInitialNotificationPayload (and the action) is still set even after it has already been used (i.e. line 79 listener(event)).

react-native-system-notification and react-native-gcm-android peer depend upon incompatible versions of each other

$ npm i --save react-native-gcm-android
[snip]
├── [email protected] 
└── UNMET PEER DEPENDENCY react-native-system-notification@^0.1.2

npm WARN [email protected] requires a peer of react-native-system-notification@^0.1.2 but none was installed.
$ npm i --save react-native-system-notification
[snip]
├── UNMET PEER DEPENDENCY [email protected]
└── [email protected] 

npm WARN [email protected] requires a peer of react-native-gcm-android@^0.1.9 but none was installed.

This appears to be down to peer dependency version mismatching, as ^0.1.9 refers to ">=0.1.9 < 0.2.0" rather than ">=0.1.9 < 1.0.0".

$ npm i --save [email protected] works as expected, as [email protected] depends upon [email protected], whereas all [email protected] versions depend upon [email protected] or lower.

iOS red screen - EventEmitter

Launching the app in iOS makes a red screen, error message being "Unable to resolve module EventEmitter from /User/.../node_modules/react-native-system-notification/index.js: Invalid directory /Users/node_modules/EventEmitter"
However, I noticed that variable EventEmitter is declared but not used in index.js

Support for System Icons

Add some way of doing using system drawables rather than requiring a resource in the mipmap folder:

setSmallIcon(android.R.drawable.stat_notify_sync_noanim)

[RN-0.31.0] Issue in FCM Listener

Hi team, pasting portion of my output after running my app , after configuring system notification.
following are my module versions :
"react": "15.2.1",
"react-native": "0.31.0",
"react-native-fcm": "^1.0.16",
"react-native-system-notification": "^0.2.1"

ERROR :
-DATE
:react-native-system-notification:prepareReleaseDependencies
:react-native-system-notification:compileReleaseAidl UP-TO-DATE
:react-native-system-notification:compileReleaseRenderscript UP-TO-DATE
:react-native-system-notification:generateReleaseBuildConfig UP-TO-DATE
:react-native-system-notification:generateReleaseAssets UP-TO-DATE
:react-native-system-notification:mergeReleaseAssets UP-TO-DATE
:react-native-system-notification:generateReleaseResValues UP-TO-DATE
:react-native-system-notification:generateReleaseResources UP-TO-DATE
:react-native-system-notification:mergeReleaseResources UP-TO-DATE
:react-native-system-notification:processReleaseManifest UP-TO-DATE
:react-native-system-notification:processReleaseResources UP-TO-DATE
:react-native-system-notification:generateReleaseSources UP-TO-DATE
:react-native-system-notification:processReleaseJavaRes UP-TO-DATE
:react-native-system-notification:compileReleaseJava
/Users/rimneshfernandez/work/projects/curation/node_modules/react-native-system-notification/android/src/main/java/io/neson/react/notification/FCMNotificationListenerService.java:9: error: package com.google.firebase.messaging does not exist
import com.google.firebase.messaging.FirebaseMessagingService;
^
/Users/rimneshfernandez/work/projects/curation/node_modules/react-native-system-notification/android/src/main/java/io/neson/react/notification/FCMNotificationListenerService.java:10: error: package com.google.firebase.messaging does not exist
import com.google.firebase.messaging.RemoteMessage;
^
/Users/rimneshfernandez/work/projects/curation/node_modules/react-native-system-notification/android/src/main/java/io/neson/react/notification/FCMNotificationListenerService.java:13: error: cannot find symbol
public class FCMNotificationListenerService extends FirebaseMessagingService {
^
symbol: class FirebaseMessagingService
/Users/rimneshfernandez/work/projects/curation/node_modules/react-native-system-notification/android/src/main/java/io/neson/react/notification/FCMNotificationListenerService.java:22: error: cannot find symbol
public void onMessageReceived(RemoteMessage remoteMessage) {
^
symbol: class RemoteMessage
location: class FCMNotificationListenerService
/Users/rimneshfernandez/work/projects/curation/node_modules/react-native-system-notification/android/src/main/java/io/neson/react/notification/FCMNotificationListenerService.java:34: error: cannot find symbol
private void sendNotification(RemoteMessage remoteMessage) {
^
symbol: class RemoteMessage
location: class FCMNotificationListenerService
/Users/rimneshfernandez/work/projects/curation/node_modules/react-native-system-notification/android/src/main/java/io/neson/react/notification/FCMNotificationListenerService.java:21: error: method does not override or implement a method from a supertype
@OverRide
^
/Users/rimneshfernandez/work/projects/curation/node_modules/react-native-system-notification/android/src/main/java/io/neson/react/notification/FCMNotificationListenerService.java:39: error: cannot find symbol
sendOrderedBroadcast(i, null);
^
symbol: method sendOrderedBroadcast(Intent,)
location: class FCMNotificationListenerService
/Users/rimneshfernandez/work/projects/curation/node_modules/react-native-system-notification/android/src/main/java/io/neson/react/notification/FCMNotificationListenerService.java:64: error: incompatible types: FCMNotificationListenerService cannot be converted to Context
NotificationManager nm = new NotificationManager(this);
^
Note: /Users/rimneshfernandez/work/projects/curation/node_modules/react-native-system-notification/android/src/main/java/io/neson/react/notification/NotificationEventReceiver.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/rimneshfernandez/work/projects/curation/node_modules/react-native-system-notification/android/src/main/java/io/neson/react/notification/WritableNativeMap.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
8 errors
:react-native-system-notification:compileReleaseJava FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-system-notification:compileReleaseJava'.

    Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 3.983 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

Need Assistance.
Thanks in advance

React Native 0.29 breaks this plugin

Can no longer do new NotificationPackage(this)

According to the release notes, plugin will need to extend ReactContextBaseJavaModule and use getCurrentActivity.

I tried briefly to fix but getting an error trying to resolve getCurrentActivity. I'm also getting package name errors (names that do not correspond to the file path).

trouble installing

on installing I see ' UNMET PEER DEPENDENCY react-native-gcm-android@^0.1.8', but trying to install that, it says 'react-native-system-notification' is unmet. is there any around this you know of?

Thanks

Build error

Hi,

I'm getting the following error. Anyone have any idea on what could be causing this?
Thanks!

  "react": "~15.2.1",
  "react-native": "~0.31.0",
  "react-native-system-notification": "^0.2.1",

:react-native-system-notification:prepareComGoogleAndroidGmsPlayServicesGcm810Library
:react-native-system-notification:prepareOrgWebkitAndroidJscR174650Library
:react-native-system-notification:prepareReleaseDependencies
:react-native-system-notification:compileReleaseAidl
:react-native-system-notification:compileReleaseRenderscript

FAILURE: Build failed with an exception.

  • What went wrong:
    Failed to capture snapshot of output files for task 'compileReleaseRenderscript' during up-to-date check. See stacktrace for details.

    Could not remove entry '/APP_DIR/node_modules/react-native-system-notification/android/build/generated/res/rs/release' from cache outputFileStates.bin (/APP_DIR/android/.gradle/2.4/taskArtifacts/outputFileStates.bin).

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Delayed/Scheduled Notification firing too late

I had the issue that some delayed/scheduled Notifications using delay or sendAt are sometimes firing up to a minute later. In case anyone else has this issues and needs a solution, it's because this API uses AlarmManager.set in Notification.java which is inexact since SDK version >= 19.
I switched to AlarmManager.setExact instead and I haven't seen any notifications firing late yet. See also this question on stackoverflow.
Not sure if this should be the new standard though as this approach consumes more resources / battery power in comparison with the other.

smallIcon not showing

Hi,

I'm having issues with displaying any other smallIcon. Code below:

    Notification.create({
        subject: "Subjecasdast",
        message: "sss",
        smallIcon: 'ic_launcher',
    });

I always get the same icon.

image

Folder structure looks like this (ic_launcher.png-files are in each folder!)

image

Any ideas why this isn't working? The icon is showing in the app drawer.

Using 0.1.6.

Background Notification Not Shown

Hi,
I am trying to use https://github.com/oney/react-native-gcm-android with this other component to receive Notifications on Android. However when the app is on the background, I am not able to display anything. I am posting my logcat and code.

The notification is received, but when I try to create it, I don't see anything. I wasn't adding the "small icon", so I thought it was failing for this reason. However, even after creating one, I am not getting anything.

GcmAndroid.addEventListener('notification', function(notification){
             console.log('receive gcm notification', notification);
             console.log(GcmAndroid.isInForeground);
             //var info = JSON.parse(notification.data.info);
        if (!GcmAndroid.isInForeground) {
                    console.log("Hello!");
          Notification.create({
            subject: "hello",
            message: "hello",
       smallIcon: "ic_stat_icon"
          });
        }
         });
06-09 13:25:38.810 28402 28402 D com.oney.gcm.GcmModule: GCMReceiveNotification BroadcastReceiver
06-09 13:25:38.813 28402 28710 I ReactNativeJS: 'receive gcm notification', { data: { default: 'ee', collapse_key: 'do_not_collapse' } }
06-09 13:25:38.835 28402 28711 I ReactSystemNotification: Notification Show: 87295
06-09 13:25:38.835 28402 28711 I ReactSystemNotification: Notification Created: 87295
06-09 13:25:38.842   650   650 E NotificationService: Not posting notification without small icon: Notification(pri=1 contentView=null vibrate=default sound=default tick defaults=0x7 flags=0x11 color=0x00000000 vis=PRIVATE)
06-09 13:25:38.873   650   650 E NotificationService: WARNING: In a future release this will crash the app: com.canddi
06-09 13:25:52.535   650  4185 D NetlinkSocketObserver: NeighborEvent{elapsedMs=2063216972, 192.168.1.1, [5203552F9596], RTM_NEWNEIGH, NUD_REACHABLE}
06-09 13:26:00.005   650  4185 D NetlinkSocketObserver: NeighborEvent{elapsedMs=2063224442, 192.168.1.1, [5203552F9596], RTM_NEWNEIGH, NUD_STALE}

When repeatCount = 1 there is not notification created

I'm trying to set a Schedule Notification in the future for only one time, I tried with delay but I got an int 32 error as "delay" number was too long (it was more than a month delay), so I tried with sentAt and repeateCount = 1 and it doesn't work...

npm WARN [email protected] requires a peer of react-native-gcm-android@^0.2.0 but none was installed.

When I initially tried to install, I got:

$ npm install react-native-system-notification --save
[email protected] /Users/alex/git/aFitness2
├── UNMET PEER DEPENDENCY react-native-gcm-android@^0.2.0
└── [email protected] 

npm WARN [email protected] requires a peer of react-native-gcm-android@^0.2.0 but none was installed.

I then ran:

$ npm i --save react-native-gcm-android
[email protected] /Users/alex/git/aFitness2
└── [email protected] 

and then:

$ npm install react-native-system-notification --save

App fails while building

After adding all the package requirement, I rebuild project, restarted the packager and tried to run. But build fails. I'm using RN 0.20

FAILURE: Build failed with an exception.

  • What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

Without GCM?

I only need local push notification with mqtt, so can I use this module without react-native-gcm-android?

License information

Hey,

thanks for your awesome library. It works like a charme on Android and I'll use it in production. Unfortunately I’ve seen, that there’s no LICENSE file defined at the github repo. Is it possible with your license, using it in production? If it’s possible can you please put a LICENSE file in the repo?

Thanks a lot!

René

BACKGROUND ISSUE: launching app, that is running in background didnt trigger press event listener

node modules versions:
"react": "^15.2.1",
"react-native": "^0.31.0",
"react-native-system-notification": "^0.2.0",
"react-native-fcm": "^1.0.16",

tried with "react-native": "^0.29.0", also.
have made all config changes told in react-native-system-notification docs.added android:launchMode="singleTask" in manifest file. and issue of app loading every time , even when launching from background got solved, now it resumes. So after that the event listener is not working.
Notification.addListener('press', function(e) {
console.log(e);
});
the listener works when app is running in the foreground. But in the background app launches on clicking notification but event listener not triggered.
Any Suggestions ?
Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.