Giter Site home page Giter Site logo

nativescript's Introduction

Notifications Scheduler

IMPORTANT: In order to use the custom com.pip3r4o.android.app.IntentService implementation, you need to install the nativescript-android-utils package as a plugin in your application.

Note:: This demo is using android.app.NotificationChannel which is available only for API 26+ (Android 8 and above).


To see an iOS version of this sample please check - https://github.com/NativeScript/sample-ios-background-execution

A sample project demonstrating how Android background services work in NativeScript, using the Android AlarmManager to schedule periodical calling of an IntentService, which should create Notifications even when the Application's Activities have been destroyed. (Caution: Be very mindful when developing applications which send out notifications. Some users may find them annoying, if they get them too often, and as a result - delete your application.)

Running the sample

    git clone https://github.com/NativeScript/sample-android-background-services
    cd sample-android-background-services
    tns run android

Notes

  • IntentService’s onHandleIntent will execute on the main UI thread (versus on a dedicated worker Thread when implemented in pure Android) IntentService’s implementation needs to use a constructor that takes no arguments, but that currently is not possible through Java.
  • The base Service class and all its descendants execute on the main UI thread by default in Android. Implementing a service that should run on a background thread must be managed in Java by the developer (see Notes).
  • BroadcastReceivers should not be registered with the android: process =":remote" property in the AndroidManifest as the receiver will be unable to execute JavaScript in an independent process
  • The suggested approach when you want to offload a long-running job on a different Thread is to write the implementation in Java classes and invoke the job in NativeScript.
  • The current implementation utilizes the NotificationChannel, which was added in API Level 26. If you want to target lower API Levels, take a look at the older implementation Alarm Manager Implementation. Have in mind, that this approaches is not supported with API Level 26 or newer due to limitations in the OS.

nativescript's People

Contributors

svetoslavtsenov avatar nickiliev avatar petekanev avatar etabakov avatar dtopuzov avatar adjenkov avatar

Watchers

James Cloos avatar Alsahid 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.