GithubHelp home page GithubHelp logo

invertase / notifee Goto Github PK

View Code? Open in Web Editor NEW
1.7K 17.0 197.0 32.63 MB

⚛️ A feature rich notifications library for React Native.

Home Page: https://notifee.app

License: Apache License 2.0

JavaScript 0.86% TypeScript 37.66% Ruby 0.95% Java 32.31% Objective-C 11.78% Starlark 0.20% Shell 0.37% Kotlin 0.01% Swift 0.88% Dart 13.37% HTML 0.36% CMake 0.02% C++ 0.66% Objective-C++ 0.57%
android hactoberfest ios notifications react-native

notifee's Introduction


Notifee Notifications

Chat on Discord


A feature rich Android & iOS notifications library for React Native.

> Learn More


Notifee is going Noti-'free' - free and fully open source. [Learn more]


Documentation

Android

The APIs for Android allow for creating rich, styled and highly interactive notifications. Below you'll find guides that cover the supported Android features.

Topic
Appearance Change the appearance of a notification; icons, colors, visibility etc.
Behaviour Customize how a notification behaves when it is delivered to a device; sound, vibration, lights etc.
Channels & Groups Organize your notifications into channels & groups to allow users to control how notifications are handled on their device
Foreground Service Long running background tasks can take advantage of an Android Foreground Service to display an on-going, prominent notification.
Grouping & Sorting Group and sort related notifications in a single notification pane.
Interaction Allow users to interact with your application directly from the notification, with actions.
Progress Indicators Show users a progress indicator of an on-going background task, and learn how to keep it updated.
Styles Style notifications to show richer content, such as expandable images/text, or message conversations.
Timers Display counting timers on your notification, useful for on-going tasks such as a phone call, or event time remaining.

iOS

Below you'll find guides that cover the supported iOS features.

Topic
Appearance Change how the notification is displayed to your users.
Behaviour Control how notifications behave when they are displayed on a device; sound, crtitial alerts, etc.
Categories Create & assign categories to notifications.
Interaction Handle user interaction with your notifications.
Permissions Request permission from your application users to display notifications.

License


Built and maintained by Invertase.

notifee's People

Contributors

bang9 avatar cabljac avatar dackers86 avatar darkace01 avatar ehesp avatar helenaford avatar kailashchoudhary11 avatar ken0nek avatar liamjones avatar lukebars avatar mars-lan avatar meypod avatar mikehardy avatar mkolakoglu avatar mohamedabkal avatar mohammadazimi avatar nahakiole avatar nateshmbhat avatar neopcl avatar parsa-j42 avatar russellwheatley avatar saeedzhiany avatar salakar avatar systemride avatar thatzacdavis avatar theduc avatar vincent-paing avatar vonovak avatar vzhovnitsky avatar wildlyspeculating 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notifee's Issues

Would it be possible to wire Notifee listeners to the events of notifications that were delivered directly to NotificationCenter?

Hi Notifee Team,
while evaluating of your library I found that the recommended way of hooking it up to the react-native-firebase is not really ideal from battery consumption perspective as it requires to boot/resume JSCore execution.

Currently, I opted in to sending an alert inside of the aps object and removing content-available header. This way, the notifications are delivered without a need to wake the app up. There is also no delay caused by the boot of JSCore in comparison to the method described in documentation.

I would like to execute onForegroundEvent or onBackgroundEvent when I tap on the notification, or notification action.

I tried to implement didReceiveNotificationResponse in my AppDelegate.m and call didReceiveNotifeeCoreEvent on NotifeeApiModule without much success.

Does anyone an idea how to achieve this?

Runtime production crash DuplicateTaskCompletionException

I just deployed Notifee to our production app and it's crashing at runtime with the following exception:

com.google.android.gms.tasks.DuplicateTaskCompletionException: Complete with: result Done

Notifee is the only library in the project using play-services-tasks. We're only using local timestamp triggered notification like so:

const trigger: TimestampTrigger = {
            type: TriggerType.TIMESTAMP,
            timestamp: time.getTime(),
        }

        // Create a trigger notification
        await notifee.createTriggerNotification(
            {
                id,
                title,
                body: message,
                data,
                android: {
                    channelId: "default",
                    smallIcon: "@drawable/ic_notification",
                    largeIcon: "@mipmap/ic_launcher",
                    color: "#f12317",
                    pressAction: {
                        id: "default",
                        launchActivity: "default",
                    },
                },
            },
            trigger
        )

This seems to be affecting a large percentage of users across all device models and android versions. I am not certain what causes the crash at the moment and don't have a reproduction yet.

[Request] There should be Sample app or Example project

Even after more than 6 months, we are still struggling sometimes to get few basic things working.
Having sample example code with main and essential functionality or demonstration will surely help to avoid many issues and I guess, it might also attract more customers.

Investigate iOS E2E timeouts

After the initial CI buildout and fixing #50 (upstream PR still in progress) ios e2e was working I thought
Then perhaps after the #54 I think it may have stopped getting reports for some reason and now cancels out

As a side project, it would be cost optimal if there was a way to run the E2E items in the open source repo vs the private core repo, but that is likely a separate thing - just mentioning it here

How to light up screen when lockscreen visibility is "Public"

I'm successfully displaying notifications on Android device lockscreens.

But the device screen does not light up when the notification is triggered.

When I press a button to wake up the screen then the notification is displayed.

Is it possible to trigger the screen to light up for a period when displaying the notification on the device lock screen?

Thanks.

[Android] No notifications are received during a phone call

Hi all!
I don't receive notifications during a phone call.

I used "@notifee/react-native": "^1.7.0" for display notification.

Steps to reproduce:

Code

Click To Expand

package.json:

{
    "name": "MyProject",
    "version": "0.0.1",
    "private": true,
    "scripts": {
      "android": "react-native run-android",
      "ios": "react-native run-ios",
      "start": "react-native start",
      "test": "jest",
      "lint": "eslint .",
      "postinstall": "npx jetify",
      "build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/myproject/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'"
    },
    "dependencies": {
      "@ingenuity-labs/react-native-api-client-wrapper": "^1.0.7",
      "@ingenuity-labs/react-native-async-storage-wrapper": "^1.0.3",
      "@notifee/react-native": "^1.7.0",
      "@react-native-community/checkbox": "^0.5.6",
      "@react-native-community/clipboard": "^1.5.1",
      "@react-native-community/geolocation": "^2.0.2",
      "@react-native-community/masked-view": "^0.1.10",
      "@react-native-community/netinfo": "^6.0.0",
      "@react-native-community/picker": "^1.8.1",
      "@react-native-community/progress-bar-android": "^1.0.4",
      "@react-native-community/progress-view": "^1.3.0",
      "@react-native-community/slider": "^3.0.3",
      "@react-native-community/toolbar-android": "0.1.0-rc.2",
      "@react-native-firebase/app": "^11.1.2",
      "@react-native-firebase/crashlytics": "^11.1.2",
      "@react-native-firebase/messaging": "^11.1.2",
      "@react-navigation/drawer": "^5.9.3",
      "@react-navigation/native": "^5.7.5",
      "@react-navigation/stack": "^5.9.2",
      "@types/jest": "^26.0.23",
      "buffer": "^6.0.3",
      "convert-string": "^0.1.0",
      "galio-framework": "^0.7.1",
      "lodash.debounce": "^4.0.8",
      "moment": "^2.29.1",
      "react": "^16.11.0",
      "react-chat-elements": "^10.12.0",
      "react-dom": "^17.0.1",
      "react-native": "^0.63.4",
      "react-native-android-immersive-mode": "^1.3.0",
      "react-native-animatable": "^1.3.3",
      "react-native-awesome-alerts": "^1.4.2",
      "react-native-background-fetch": "^4.0.2",
      "react-native-background-timer": "^2.4.1",
      "react-native-ble-manager": "^7.4.2",
      "react-native-ble-peripheral": "^2.0.1",
      "react-native-bluetooth-status": "^1.5.1",
      "react-native-collapsible": "^1.5.3",
      "react-native-date-picker": "^3.2.10",
      "react-native-default-preference": "^1.4.3",
      "react-native-device-info": "^8.1.2",
      "react-native-dropdown-picker": "^3.7.1",
      "react-native-elements": "^2.3.2",
      "react-native-exit-app": "^1.1.0",
      "react-native-fs": "^2.16.6",
      "react-native-gesture-handler": "^1.8.0",
      "react-native-i18n": "^2.0.15",
      "react-native-navigation-bar-color": "^2.0.1",
      "react-native-nfc-manager": "^3.3.0",
      "react-native-notification-sounds": "^0.5.3",
      "react-native-pdf": "^6.3.0",
      "react-native-raw-bottom-sheet": "^2.2.0",
      "react-native-really-awesome-button": "^1.6.0",
      "react-native-reanimated": "^1.13.1",
      "react-native-responsive-dimensions": "^3.1.1",
      "react-native-responsive-screen": "^1.4.2",
      "react-native-safe-area-context": "^3.1.8",
      "react-native-screens": "^2.11.0",
      "react-native-set-app-icon": "0.0.9",
      "react-native-side-menu-updated": "^1.2.1",
      "react-native-sound": "^0.11.0",
      "react-native-super-grid": "^4.0.3",
      "react-native-system-setting": "^1.7.5",
      "react-native-v8": "^0.63.4-patch.1",
      "react-native-vector-icons": "^6.7.0",
      "react-native-version-check": "^3.4.2",
      "react-native-volume-control": "^1.0.1",
      "react-navigation": "^4.4.3",
      "react-navigation-drawer": "^2.6.0",
      "react-navigation-stack": "^2.10.2",
      "react-onclickoutside": "^6.9.0",
      "react-redux": "^7.2.2",
      "redux": "^4.0.5",
      "rn-fetch-blob": "^0.12.0",
      "ts-jest": "^26.5.6",
      "typescript": "^4.2.4",
      "v8-android-jit": "^9.88.0"
    },
    "devDependencies": {
      "@babel/core": "7.6.4",
      "@babel/runtime": "7.6.3",
      "@react-native-community/eslint-config": "0.0.5",
      "babel-jest": "24.9.0",
      "eslint": "6.6.0",
      "jest": "24.9.0",
      "jetifier": "^1.6.6",
      "metro-react-native-babel-preset": "0.57.0",
      "react-test-renderer": "16.9.0"
    },
    "jest": {
      "preset": "react-native"
    }
  }
  

High importance notification disappears into the notification shade after 5 or 6 seconds

When showing a high importance notification on Android when the app is in the background but the phone is unlocked, the notification disappears in to the notification shade after 5 or 6 seconds. This is undesirable to say notify someone of an incoming call, because if they look at the device after the notification has been 'minimised' and a ring tone is playing for example, it provides a bad UX.

The ideal scenario is to give the option to make the notification persistent.

Is there a way to override this or add this as a feature request? I have tried setting:

      android: {
        ongoing: true,

but it makes no difference.

Press event listener delay

Hi!

So, I'm trying to migrate from react-native-firebase v5 to react-native-firebase v6 + notifee, but I'm having some trouble maintaining the behaviour I had before in my app due to the delay that notifee seems to have between the user actually pressing a notification and the event being triggered so I can handle it.

What I was doing before was:

// Displaying notification using react-native-firebase/notifications
firebase.notifications().displayNotification(notification);

// Handle notification press event
this.removeNotificationOpenedListener = firebase.notifications().onNotificationOpened(notification => {
  this.handleNotificationOpened(notification);
});

With this approach, the event is triggered almost immediately, taking an average of 50ms between the actual press and the event trigger.

And what I'm doing now is:

// Displaying notification using `notifee`
notifee.displayNotification(notification);

// Handle notification press event
this. removeNotificationOpenedListener = notifee.onForegroundEvent(({ type, detail }) => {
  if (type === EventType.PRESS) {
    return this.handleNotificationOpened(detail.notification);
  }
});

With this approach I'm seeing a delay between the press of the notification and the event being triggered of an average of 2 seconds each time. I was able to catch it taking more than 3 seconds at times. This totally breaks the UX I had before, because the user can interact with the app before the event is triggered.

Example use case:
The user has the app in background, he clicks a notification and the app opens. First thing he sees when the app opens is the pin/face id/ touch id screen. With my previous approach when the user was done inserting the pin I already had the info of what notification caused the app to open so I could redirect him to where I wanted immediately. Now, using notifee, the user can insert the pin and see the app's initial screen for a while and only then is redirected to where I want him to be, because only then I could know that a notification was pressed.

Am I doing something wrong? Am I not using the correct approach? Can we do something about the delay?

Note: using onForegroundEvent for background events also, due to #136.

Integration with react-native-firebase

Hi, I have purchased a license from Notifee and am trying to integrate it with react-native-firebase messaging.

I have first added all the react-native-firebase settings.

Then i see the integration guide of your page

But it has not worked well.

On integration guide say:

import messaging from '@react-native-firebase/messaging';

function onMessageReceived(message) {
  // Do something
}

messaging().onMessage(onMessageReceived);
messaging().setBackgroundMessageHandler(onMessageReceived);

But on react-native-firebase say to add this on root index.js:

import messaging from '@react-native-firebase/messaging'
import AsyncStorage from '@react-native-community/async-storage'
// Register background handler
messaging().setBackgroundMessageHandler(async remoteMessage => {
  console.log('Message handled in the background!', remoteMessage)

  let messageArray = []
  const currentMessages = await AsyncStorage.getItem('messages')
  if (currentMessages) {
    messageArray = JSON.parse(currentMessages)
  }

  messageArray.push(remoteMessage)
  await AsyncStorage.setItem('messages', JSON.stringify(messageArray))
})

const HeadlessCheck = ({ isHeadless }) => {
  if (isHeadless) {
    // App has been launched in the background by iOS, ignore
    return null
  }

  return <App />
}

HeadlessCheck.propTypes = {
  isHeadless: PropTypes.bool
}

AppRegistry.registerComponent(appName, () => HeadlessCheck)

With messaging().setBackgroundMessageHandler(onMessageReceived); in my App component it doesnt work.

With react-native-firebase documentation it works, but always display his own notification. And i cant catch notification press event.

I need catch background notification press, or hide it and show with notifee.

EDIT:
I added this and now i can get the bg or closed app notif data

 const initialNotification = await messaging().getInitialNotification()
      if (initialNotification) {
        console.log('getInitialNotification initialNotification', initialNotification)
      }

Issue with iOS Service Extension and notifee_options when app in foreground

Issue:

Looking to add images to our iOS notifications. I was able to utilize the service extension as documented here -https://notifee.app/react-native/docs/ios/remote-notification-support. Using the FCM Console to send test messages.
Everything worked fine till I tried modify bestAttemptContent to add the notifee_options. It works properly while the app is closed\background. When the app is in the Foreground, the notification is not shown. I did see where "content-available" is required to fire onMessage when app is in foreground, but onMessage did fire with the FCM Message just as it was sent from the testing console. I did test adding (test 2) with adding "content-available" in the same fashion as I added "notifee_options"...but maybe that's not valid 🤷🏼‍♂️
Details on testing, messages sent, and variations below:

Setup

Message sent via Firebase Test Console(derived from self.bestAttemptContent.userInfo in the service extension call:

{
   aps :  {
      alert : {
         body : "Shop Now!",
         title : "Back to School TECH Deals Are Here"
      },
      "mutable-content" : 1
   },
   "fcm_options" :  {
      image : "https://fanart.tv/fanart/movies/15596/movieposter/back-to-school-568913d00c872.jpg"
   }
}

Tests:

Test 1 - Notifee Service Extension:

Service extension code with Notifee changes

 - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
    self.contentHandler = contentHandler;
    self.bestAttemptContent = [request.content mutableCopy];

  [NotifeeExtensionHelper populateNotificationContent:self.bestAttemptContent withContentHandler:contentHandler];
}

Results :

  • Background\Dead: Service Extension is called, Shows notification - no image
  • Foreground: Service Extension is called, messaging().onMessage() is called, displays notification correctly via use of notifee.displayNotification

Test 2 - Notifee as written in the guide with modified message from FCM to include notifee_options and content-avaialble:

Object passed to populateNotificationContent

{
   aps :  {
      alert : {
         body : "Shop Now!"
         title : "Back to School TECH Deals Are Here"
      },
      "mutable-content" : 1,
      "content-available" : 1
   },
   "fcm_options" :  {
      image : "https://fanart.tv/fanart/movies/15596/movieposter/back-to-school-568913d00c872.jpg"
   },
   "notifee_options" :  {
      image : "https://fanart.tv/fanart/movies/15596/movieposter/back-to-school-568913d00c872.jpg"
   }
}

Code used to modify object:

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
    self.contentHandler = contentHandler;
    self.bestAttemptContent = [request.content mutableCopy];
    
  NSDictionary *fcmOptions = self.bestAttemptContent.userInfo[@"fcm_options"];
  NSString *imageUrl = fcmOptions[@"image"];
  
  NSMutableDictionary *mutableUserInfo = [self.bestAttemptContent.userInfo mutableCopy];
  
  //Need to add notifee_options: {image: imageUrl} to user info
  NSString *imageKey =@"image";
  NSDictionary * imageDict =@{imageKey:imageUrl};
  
  [mutableUserInfo setValue:imageDict forKey:@"notifee_options"];
  
  //Need to add 'content-available': 1, // Important, to receive `onMessage` event in the foreground when message is incoming
  NSMutableDictionary *mutableAps = [self.bestAttemptContent.userInfo[@"aps"] mutableCopy];
  NSNumber *numWthType = [NSNumber numberWithInt:1];
  [mutableAps setValue:numWthType forKey:@"content-available"];
  [mutableUserInfo setValue:mutableAps forKey:@"aps"];

  self.bestAttemptContent.userInfo = [NSDictionary dictionaryWithDictionary:mutableUserInfo];
  NSLog( @"UserInfo after => '%@'", self.bestAttemptContent.userInfo );

  [NotifeeExtensionHelper populateNotificationContent:self.bestAttemptContent withContentHandler:contentHandler];

Results:

  • Background\Dead: Service Extension is called, Shows notification with image
  • Foreground: Service Extension is called, Notification is not displayed

Test 3 - Using self.contentHandler(self.bestAttemptContent); instead of notifee handler modified message from FCM to include

In order to test if my code was an issue, I went back to the following code for the service extension.

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
    self.contentHandler = contentHandler;
    self.bestAttemptContent = [request.content mutableCopy];

  self.contentHandler(self.bestAttemptContent);
}

Results:

  • Background\Dead: Service Extension is called, Shows notification - no image
  • Foreground: Service Extension is called, messaging().onMessage() is called, displays notification correctly via use of notifee.displayNotification

Notifee version: 1.9.2

info Fetching system and libraries information...
System:
OS: macOS 11.4
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 1.70 GB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 15.3.0 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.0.14 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.0 - /Users/ccornelius/.rvm/gems/ruby-2.7.2/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK: Not Found
IDEs:
Android Studio: 4.1 AI-201.8743.12.41.6953283
Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
Languages:
Java: 15.0.1 - /Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.4 => 0.63.4
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

NotificationPressAction with launchActivity: 'default' not working on device lock screen

Hi! I am having trouble with the following problems. Would it be okay if I asked you to help me?

[Problem]

  • Application will not launch after tap NotificationPressAction which has launchActivity: 'default' on lock screen

[Condition]

  • Only on android
  • !!!Important!!!: Lock screen settings should be "Show all notification content" (Settings>Privacy>Lock screen)

[Code]

    const notifee = require('@notifee/react-native').default;
    const channelId = await notifee.createChannel({
      id: 'default',
      name: 'Default Channel'
    });
    await notifee.displayNotification({
      title: 'title',
      body: 'body',
      android: {
        channelId,
        actions: [
          {
            title: 'Open',
            pressAction: {
              id: 'open',
              launchActivity: 'default'
            }
          }
        ]
      }
    });

[Steps to reproduce]

  1. Set lock screen "Show all notification content" (Settings>Privacy>Lock screen)
  2. Display notification with above code
  3. Press the power button
  4. Press the power button again to get lock screen
  5. Tap "Open" on notification on lock screen, application will not launch.

Thanks for your great works!

iOS Remote Notifications without Firebase

Hello, I've seen that recently notifee introduced the support for remote notifications on iOS which would simplify my application a lot, am I wrong to assume that for this feature to work, firebase is required for iOS as well?

I already have a notification extension inside my app which handles read receipts for notifications, What I'm missing is how to make my remote notifications events appear as notifee events inside my app.

Is there a protocol I could follow to forward the events (press, quick action) of my remote notifications to notifee?

Thank you for your time and the amazing work you've done with this library!

Add GH_TOKEN to notifee repository for PR Title workflow

The PR Title workflow that verifies the title is conventional is failing, I think it is because the GH_TOKEN secret is not defined for the repository?

it is used like so (identical to the react-native-firebase repo, so it should work, making me think the token is repo-specific)

          GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

I believe adding a token with the same permissions as the GH_TOKEN defined in react-native-firebase repo will allow the PR title check to pass

[Android] Start foreground service on boot?

I'm using the foreground service functionality, but I'd like it to start on boot and not require the user to open the App to launch it. I don't see anything in the docs, and my attempts to create something that receives the BOOT_COMPLETED action to start the Notifee service don't seem to work.

android quick action setting input to true causes an 'null' error

In the docs, notes to set input to true to enable free text however this causes an internal module error on Android.
Works if input is set to an empty object.

https://notifee.app/react-native/reference/androidaction#input

notifee.displayNotification({
  title: 'New message',
  body: 'You have a new message from Sarah!',
  android: {
    channelId: 'messages',
    actions: [
      {
        title: 'Reply',
        icon: 'https://my-cdn.com/icons/reply.png',
        pressAction: {
          id: 'reply',
        },
        input: true, // enable free text input
      },
    ],
  },
});

Screenshot 2021-05-21 at 16 35 14

ids on Android can't be retrieved from `getDisplayedNotifications`

  • When a notification is created with notifee, the id passed down is converted from a string to an int by its hashcode
  • When the notification is retrieved from the notification tray (as a StatusBarNotificaiton), the id that is returned is the hascode and not the original string.

This causes a problem when trying to cancel the notification with the id returned from getDisplayedNotifications because the notificationId will already be the correct int, so the following will not work:
notificationManagerCompat.cancel(notificationId.hashCode());

It also causes an issue when cancelling a remote notification. It's possible to cancel a remote notification with the correct id and tag ( notificationManagerCompat.cancel("fcm-tag", 0);.

Possible solutions:

  1. Expand the API cancelNotification to specify if the id is already a valid 32 int (no need to convert the string to its hashcode. e.g. cancelNotification(id: string, {isValidInt: boolean, tag: string | null } )`
    Not sure if using a boolean to determine if the string needs to be converted to a valid integer is confusing, over-complicated.
  2. ???

Custom notification sound when phone is in Do not disturb mode

I am using notifee to receive push notification in my application. I am able to receive the notifications in Do not disturb mode but could not play the custom sound when notification is received.
Do we have any method to implement custom sound in Do not disturb mode for priority notifications.

bypassDnd not working

Hi,
I created a Android Channel with setting bypassDnd: true. But in the device Notification Settings the "Override Do Not Disturb" is still showing disabled. Seems the bypassDnd has no effect while creating a channel.

Notifee version: 0.15.1
Android 10

[iOS] System sound instead of custom sound for push notification plays when the app is in killed(Not lauched) state

We want to allow users to select notification sounds based on their choice from the pre-defined list. So we have done everything like adding files and all.
What we are able to achieve is when the app is opened and push notification comes the custom sound plays just fine but when the app is in a killed state and if the notification receives then it plays the system default sound.
Please guide me if I am going anything wrong or Am I missing anything?

Missing api endpoints

  • getDisplayedNotifications() - return notifcations from notificaiton tray
  • getTriggerNotifications() - return trigger notification (similar to getTriggerNotificationIds())
  • cancelDisplayedNotifications(ids) - allow to be able to remove an array of notifications at once
  • channelExists(id) - check if a channel exists
  • channelBlocked(id) - check if a channel is blocked

[question] APNs integration

Hello!
I've got some questions regarding integrating with APNs because I'm not sure where "notifee's responsibility" starts and ends.

The idea is following: on iOS, I'm not using firebase and so I'd like to use https://github.com/react-native-community/push-notification-ios to get APNs token only (and deliver it to a server which will send the remote notifications). That means I only implement

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
  [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
}

and then I want to use Notifee to react to when notification is received (both when app is in background and foreground) and when it is pressed by user, including actions offered in the notification. It appears that events should handle just that - ?

So far I was able to get notification delivered on android with fcm, and the onForegroundEvent as well as onBackgroundEvent are fired in JS (I just made a console.log there and found it in logcat).

When I tried to do the same on ios, I only managed to get the push notification delivered when the app is in background / killed (so remote notifications are delivered, getting the APNs token seems to work). Now, when I try to subscribe for the events in JS, I unfortunately don't receive any :/

I'm aware of this comment and the implementation.

Unfortunately, since the native code is not open, I'm not quite sure what is going on inside and I'm not sure if my expectations are correct.

in device logs, I found

Warning: UNUserNotificationCenter delegate received call to -userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: but the completion handler was never called.

which I'm guessing might be an issue?

I'd like to ask

(1) are my expectations sensible/correct and should my JS handlers (at least the foreground one) be called? I'm registering the handlers early in the app

(2) is it theoretically possible that the event is fired from native before a listener is attached in JS? (I would understand that for the background event but not for the foreground one?). Does notifee's native code somehow wait until JS "is ready"?

(3) does notifee implement willPresentNotification and didReceiveNotificationResponse for its events functionality?

(4) any ETA for proper onBackgroundEvent support on iOS?

(5) how is onBackgroundEvent different from RNFB's messaging().setBackgroundMessageHandler? Maybe I'm mixing local and remote notifications and asking stuff that should be obvious but I didn't feel like I found answers for these in the docs. Generally, when reading docs, I keep noticing it's always documented what some library is but it's often not documented what the library is not. But otherwise the docs are really nice (I really like click-though type definitions)!

Lastly, can someone confirm that this works for them using RN 60? Maybe I should upgrade first...

Chronometer CountDown

I have a notification with a 2 minute countdown.
After these 2 minutes I want the notification to remain, but stop the counter decrementing, i want it to stop at 00:00 instead of having a negative value. A kind of timeout.
Is it possible ?

Thx.

onForegroundEvent triggered with app in background/closed

Hi!

The following behaviour is happening to me: I call displayNotification method, with my app in foreground, the notification is displayed but I don't press it and instead I send the app to background. Then, I go to the notification center and press the notification. As per the documentation, I expected an onBackgroundEvent to be triggered, but instead I am getting an onForegroundEvent. This happens even if I completely close the app and only then press the notification.

I can reproduce this behaviour both in my app and on @mikehardy 's demo project, only in iOS. Android seems to be triggering the correct events.

data object has to be duplicated in remote message

When using the notification service extension helper, the data property has to be included in notifee_options. This can cause unnecessary duplication in the payload and an increase in payload size.

Is it possible to set an Timestamp Trigger with a custom frequency?

Hi,
I want to send a notification every 3 days at a specific time, how can I do that?
As I understand I can send a notification at a specific time every hour, day or week with Timestamp Trigger and repeatFrequency.
Or I can send it to a specific interval (every 3 days, every month, etc.) but without the ability of choosing the time with the Interval Timestamp.

Is there a way to kind of mix the two triggers to send the notification at a specific time to a specific interval?

Thanks

How to use different device sound?

We are trying to change the notification sound in our local notifications by letting the user decides which sounds they want using this other library: https://www.npmjs.com/package/react-native-notification-sounds

Here is an example of sound coming from this library on android:
image
And here is an example of the data the notification sound library gives us (android): {"label": "Aldebaran", "value": {"id": "30", "title": "Aldebaran", "url": "content://media/internal/audio/media/30"}}

An example on IOS:
Image from iOS

The notifications we get from this library are all already on the device. We tried giving their names in the sound property, but we fail to get the expected outcome. We also tried to put the sound url as given by the library but since it isn't in the required folders for this library, it does not work either. For android, we have absolutely no sound. As for IOS, it's always the default sound that plays.

Is there any way to play any other system sound than the default one?

Thank you!

getInitialNotification and onForegroundEvent both fire on iOS

When a notification is pressed when the app is closed, onForegroundEvent triggered with a 'PRESS' event and getInitialNotification is populated too.

On Android, onBackgroundEvent is triggered, and getInitialNotification is populated. A workaround for Android is possible (See #83), and this might be good to have a heads up before the app finishes to mount.

Foreground notification on iPhone + AppleWatch

Hello

There was a problem.
If an AppleWatch is connected to the iPhone, notifications do not show when the application is open in Foreground.
Background works correctly.

ios & watchOS have the last version

I tried to debug - no reaction in log.
On a phone without a watch notification works correct.

The only suggestion is that the clock intercepts the notification, and does not reach the phone.

Config
const notificationsSubscribe = useCallback(async (remoteMessage) => { try { let responseObj = JSON.parse(remoteMessage.data.notifee); responseObj = { title: responseObj.title, body: responseObj.message, data: { ... }, ios: { foregroundPresentationOptions: { alert: true, badge: true, sound: true, }, sound: 'default', categoryId: 'important', }, }; await notifee.displayNotification(responseObj); } catch (e) { }

Action

const setActions = useCallback(async () => { //Events handler on press notifee.onForegroundEvent(({type, detail}) => { const {notification, pressAction, input} = detail; if (type === EventType.ACTION_PRESS && pressAction.id === 'default') { // Send message action on send reply } else { switch (type) { case EventType.DISMISSED: //action on dismiss notification break; case EventType.PRESS: ... break; } } }); }, []);

Code
useEffect(() => { messaging().onMessage(notificationsSubscribe); setActions(); return () => { messaging().onMessage(notificationsSubscribe); setActions(); }; }, []);

In what may be a problem?
Help pls

[iOS] Notification Actions Not Triggering from Apple Watch

I've been playing around with multiple libraries for push notifications:

wix/react-native-notifications
react-native-push-notification-ios/push-notification-ios

and this one right here. I've finally gotten notification actions to work properly on the phone regardless of the app being killed, or backgrounded.

I've just started testing this on the Watch and I am unable to get the action to be handled by the phone. In this library specifically the phone does not receive the notification action response when the device is locked. With react-native-push-notification-ios/push-notification-ios it's unreliable, and sometimes I get the response, sometimes I don't – it seems the responses stop coming after 30 minutes of being in the background.. probably suspended?

Anyways, it would be great to know if anyone has this working properly on their end as I don't see how I can release notification actions without them working properly on the watch. I wouldn't be surprised if it wasn't a particular notification libaries fault as I was initially unable to get notification actions working at all due to another dependency: react-native-splash-screen

`onNotificationOpened` missing

Not 100% sure if there was a reason to not implement this, but without it, it forces the developer to check if the app has been mounted before handling the press action event in the background.

notifee.onBackgroundEvent(event => {

if (event.type === "PRESS_ACTION") {
    if (AppState.currentState === 'active') {
      // Ignore, `getInitialNotification` will take care of the event
      // Occurs when app is opened from a quit state
      return
    }
    
    // Carry on handling press action event i.e. navigating user to appropriate screen
    navigate('...') 
 }
})

[Android] Wrong quick action triggered

I have three actions on my notification and for about 1/20 taps the next action is triggered instead of the tapped one (second instead of first, third instead of second).

Notification:

notifee.displayNotification({
  title: 'title',
  body: 'body',
  android: {
    channelId: 'test',
    actions: [
      {
        title: 'First',
        pressAction: {
          id: 'first',
        },
      },
      {
        title: 'Second',
        pressAction: {
          id: 'second',
        },
      },
      {
        title: 'Third',
        pressAction: {
          id: 'third',
        },
      },
    ],
  },
})

Notifee 1.10.1
React native 63

How to add vibration pattern in IOS

I am using notifee in my react native application , Notification in Android are working fine with custom sound and custom vibration.
How can I add custom vibration pattern in IOS?

below is my code

const notification = {
        title: 'Testing',
        body: "Hello Testing",
        id: 'quickAction',     
        ios: {
          sound: "pager.caf",
          categoryId: 'quickActions',
          critical: true,
          criticalVolume: 0.9,
        },
   }

notifee.displayNotification(notification);

I need to add vibration pattern in below manner
vibrationPattern:[180, 121, 134, 300, 289, 123, 134, 300, 621, 121, 134, 300, 289, 123, 134, 300]

[Android] Modify firebase remote notification

I'm wondering if there's a way to use notifee to modify a notification displayed on the device that was sent by firebase.

To give more context: in our android application, we had the following flow:

  1. Our backend would send us a data-only notification using firebase;
  2. We would combine the data in the notification with some client-side only data (namely, contact matching);
  3. We would then display a local notification using notifee with the combined backend and client data.

This flow isn't ideal because data-only notifications do not have the same priorities. I was wondering if there was a way to receive a remote notification, and then edit the displayed notification by updating its content with our client-side data in the handler registered using firebase messaging.

I've tried the naive approach of simply grabbing the id given with the firebase notification and plopping it in notifee.displayNotification as described here. I was hoping that doing so would update the content of the notification. This did not work.

My question is two-fold:

  1. Is it feasible to edit a notification that was displayed by receiving it from Firebase using plain-old Java/Kotlin native code?
  2. Is there a way to do it using notifee's API?

initialNotification populating for quick actions

initialNotification typically should be populated only if the notification is tapped. Bug with quick actions where if you perform a quick action when the app is closed (quit state), then open the app from the home screen, initialNotification is populated.

Workaround at the moment is to check the pressAction.id is default, indicating the user did press the notification to open the app

https://notifee.app/react-native/reference/getinitialnotification

Android Actions on Lockscreen and Wake Device

I am attempting to use Notifee to show a notification for an incoming Voip Call. Currently I can not make the notification load on the lockscreen with the actions visible or have the notification wake the device. Any advice would be appreciated.

async function onMessageReceived(message) {
  const { type, number, name } = message.data;

  if (type === 'invite') {
    const channelId = await notifee.createChannel({
      id: 'calls',
      name: 'Calls',
      visibility: AndroidVisibility.PUBLIC,
      importance: AndroidImportance.HIGH,
    });

    notifee.displayNotification({
      title: 'Inbound Call',
      body: `Inbound call from ${name || number}`,
      android: {
        autoCancel: false,
        channelId: channelId,
        actions: [
          {
            title: 'Answer',
            pressAction: {
              id: 'answer',
              launchActivity: 'default'
            },
          },
          {
            title: 'Dismiss',
            pressAction: {
              id: 'dismiss',
            },
          },
        ],

      },
    });
  }
}

messaging().onMessage(onMessageReceived);
messaging().setBackgroundMessageHandler(onMessageReceived);

RemoteServiceException when using foreground service on Android API 26

Start seeing the following crash when rolling out our new version that uses foreground service

Fatal Exception: android.app.RemoteServiceException
Context.startForegroundService() did not then call Service.startForeground()

android.app.ActivityThread$H.handleMessage (ActivityThread.java:1881)
android.os.Handler.dispatchMessage (Handler.java:105)
android.os.Looper.loop (Looper.java:164)
android.app.ActivityThread.main (ActivityThread.java:6938)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

So far the crash is limited to only Android 8.0 devices, but not sure if it's an artifact of the small rollout percentage or an actual version-specific issue.

Based on https://developer.android.com/about/versions/oreo/android-8.0-changes & https://developer.android.com/reference/android/app/Service#startForeground(int,%20android.app.Notification) it seems to suggest that startForeground wasn't called within 5 seconds of foreground service creation. Without any visibility into the code base, it's difficult to debug the issue further.

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.