GithubHelp home page GithubHelp logo

aviavinas / flutter_notification_channel_with_custom_sound Goto Github PK

View Code? Open in Web Editor NEW

This project forked from caseyryan/flutter_notification_channel

0.0 0.0 0.0 91 KB

firebase_messaging version 7.0.3 (current) and lower do not allow to set up a notification channel, thus notifications don't play any sounds or do not display on locked screen, or don't bubble and so on. This plugin is made merely for the purpose of creation a notification channel with difference configuration on Android. The channel then can be u

License: Other

Ruby 13.51% Objective-C 5.09% Java 30.88% Dart 44.72% Swift 5.80%

flutter_notification_channel_with_custom_sound's Introduction

flutter_notification_channel

https://pub.dev/packages/flutter_notification_channel

This plugin is made to register notification channels with custom configurations on Android. For more details read this https://developer.android.com/training/notify-user/channels Why is it necessary? E.g. firebase_messaging version 7.0.3 (current) and lower do not allow to set up a notification channel, thus notifications don't play any sounds or do not display on locked screen, or don't bubble and so on. This plugin is made merely for the purpose of creation a notification channel with custom configurations on Android. The channels then can be used along with firebase_messaging.

How to use

Simply call it like this

var result = await FlutterNotificationChannel.registerNotificationChannel(
    description: 'Your channel description',
    id: 'your_channel_id',
    importance: NotificationImportance.IMPORTANCE_HIGH,
    name: 'Your channel name',
    visibility: NotificationVisibility.VISIBILITY_PUBLIC,
    allowBubbles: true,
    enableVibration: true,
    enableSound: true,
    showBadge: true,
);
print(result);

Then, when you send a message to firebase like this, specify your android_channel_id and sound: "default" in order to play a default sound if you set "enableSound" in plugin. If you don't do this, the sound wont play at all on android 9 (I have no idea why)

{
  "notification": {
    "title": "Your message title",
    "body": "Your message body",
    "android_channel_id": "your_channel_id",
    "sound": "default"
  },
  "data": {
    "click_action" : "FLUTTER_NOTIFICATION_CLICK",
  },
  "priority": "high",
  "content_available": true,
  "to": "YOUR_FIREBASE_PUSH_TOKEN_GOES_HERE"
}

flutter_notification_channel_with_custom_sound's People

Contributors

caseyryan avatar aviavinas avatar

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.