Giter Club home page Giter Club logo

autostarter's Introduction

Autostarter

Download license API

This library helps bring up the autostart permission manager of a phone to the user so they can add an app to autostart.

Why this library?

In my experience so far when using Firebase to integrate cloud messaging or notifications in app, phones running stock android OS receive notifications perfectly whereas phones which have custom UI installed on them from the OEM such as Xiaomi, Letv do not receive any fcm calls.

This is because the OEM's by defaut add an unrecognized app to the blacklist which prevents it from running in the background and receiving notifications, apps like Whatsapp on the other hand are known apps which are whitelisted by the OEM and can hence receive notifications.

To work around this the user must allow your app to autostart which gives your app the required permission to run in the background and listen for any messages from Firebase. Unfortunately since this is an OEM specific problem and not an android sdk problem, there is no documented api for bringing up the autostart permission manager of a phone.

Each manufacturer has their own version of it with different package names, hence this library was created to curate a list of all the packages used by each OEM for their version of the autostart permissiong manager.

Usage

Gradle

Add this to your module's build.gradle file:

dependencies {
        // ... other dependencies
        implementation 'com.github.judemanutd:autostarter:1.0.8'
}

Maven

<dependency>
    <groupId>com.github.judemanutd</groupId>
    <artifactId>autostarter</artifactId>
    <version>1.0.8</version>
    <type>pom</type>
</dependency>

Once you have integrated the library calling the following function will bring up the autostart permission manager of the phone. The function returns a boolean to indicate if the action was as success or a failure.

    AutoStartPermissionHelper.getInstance().getAutoStartPermission(context)

In order to check if your phone is supported by the library you can call the following command.

     AutoStartPermissionHelper.getInstance().isAutoStartPermissionAvailable(context)

In order to keep the library small and simple I have not included any dialogs or pop ups, It is upto you to provide the user with a message if necessary.

On phones that are not running a custom UI or that do not require an autostart permission, this code will not open any new screen.

Note

As of now the library has support for the following manufacturers :

  1. Xiaomi
  2. Redmi
  3. Letv
  4. Honor [ Untested ]
  5. Oppo [ Untested ]
  6. Vivo [ Untested ]
  7. Huawei
  8. Samsung
  9. Asus
  10. One Plus [ Untested ]

I will be adding support for other manufacturers as and when possible. I am also open to PR's and contributions from others.

Related Info

Since this depends entirely on the OEM and not on android itself, the underlying component that this library makes use of is continuously changing. Do check out these repositories for further information on this issue

autostarter's People

Contributors

cedricale avatar judemanutd avatar mansya avatar rayworks avatar

Stargazers

 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.