GithubHelp home page GithubHelp logo

umeshjangid / android-notification-channels-analysis Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.25 MB

Analysis on Notification Channels.

Java 6.35% Kotlin 93.65%
android-channels android-notifications channels notification-channel notifications

android-notification-channels-analysis's Introduction

Ref and Code Taken for analysis : Github Firebase Push Notification Tutorial https://github.com/Hardik8184/FirebasePushNotification

Firebase Push Notification Tutorial

How Firebase Push Notification works?

Firebase serves as a module between your server and the devices that will be receiving the push notifications that you create. Your server informs Firebase that a notification has to be sent. Then Firebase does the work behind the scenes to get the notification published.

 

Image 1

How to integrate FCM into Android Project?

Step for creating Firebase Project

Step 1: Open Firebase console

Image 1

Step 2: Click on Add project and give name to your project and select country. If you have already created a project skip this step.

Image 1

Step 3: Then select “Add Firebase to your Android app”.

Image 1

Step 4: Add project package id or application id and genrate SHA-1 signatature of your machine.

Image 1

Step 5: Download google-service.json and put into app module.

Image 1

How to generate SHA Key using Android Studio:

  1. Open your project into Android studio.
  2. Click on Gradle tab on right side.
  3. Collapse :app module -> Tasks -> Android -> signing report.
  4. SHA-1 will generate. Copy and paste into SHA-1 in firebase console.

Image 1

How to integrate Firebase SDK into Android Project?

Step 1:

Add below code into <project>/build.gradle file.

buildscript {
  dependencies {
    // Add this line
    classpath 'com.google.gms:google-services:4.3.2'
  }
}

Step 2:

Add below code into <project> / <app>/build.gradle.

dependencies {
  // Add this line
  implementation 'com.google.firebase:firebase-messaging:20.0.0'
}
...
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'

Step 3:

Press on sync now in the Android Studio.

Now you can send Push Notification using Firebase Console

  1. Go to firebase console and select the app you created.
  2. From the left menu select notification.
  3. Click on new message.
  4. Enter message, select single device and paste the token you copied and click on send. The same as I did on the video, and check your device

Analysis On Notifications Channel Settings:

There will be majorly 2 options :

  1. Remove Notification Channel Setting which is manually done by user without user consent : Which is not possible as per android documentation. (https://developer.android.com/reference/android/app/NotificationManager#createNotificationChannel(android.app.NotificationChannel)) 
here is some findings from Internet you can check the below links as well.
 You should recreate the channel just as you created it for the first time. The createNotificationChannel command will create the channel if it hasn't been created yet, and it will update the channel if it has been already created. If the channel is already created, then the only thing you can change is the name of the channel and the channel description, nothing else. The importance will be ignored, because the user might have already changed the importance of the channel manually. But even if they hasn't changed that, still the importance won't be updated, and actually that's the purpose of the notification channels. To give freedom to the users to manage their channels, without the developers messing with them when the app is updated.
 So in summary, by declaring:
 NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, “newName”, NotificationManager.IMPORTANCE_DEFAULT); notificationManager.createNotificationChannel(notificationChannel);
 in an already created channel, the name of the channel will be updated, but not the importance. If you want to update the channel description as well, you can do that like that:
 notificationChannel.setDescription("new description"); //set that before creating the channel



So, From here we conclude that we doesn’t need option one solution, we need to override the settings of user device.



Ref 1: https://developer.android.com/training/notify-user/channels
 Ref 2: https://stackoverflow.com/questions/45081815/android-o-notification-channels-change-vibration-pattern-or-sound-type
 Ref 3: https://stackoverflow.com/questions/52364032/how-to-properly-update-notification-channel-android-oreo



2.Delete Notifications Channels and make the channels again.



To create notification channel, we will create the same channel name but we will change the channel_id for that we need to create a unique identifier. For ex. Currently we use channel id as : mydefaultchannel but to achieve or solve this case we should use mydefaultchannel1 or mydefaultchannel_1 or anyother of your choice. Channel id is never will be on the frontend or it is not be for user it is only for the system to manage settings.

Issues is open, you can write to me.

Thanks.

android-notification-channels-analysis's People

Contributors

umeshjangid avatar

Watchers

 avatar  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.