All Projects → NativeScript → sample-ios-background-execution

NativeScript / sample-ios-background-execution

Licence: other
Running Custom Background Tasks with NativeScript

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
CSS
56736 projects

Running Custom Background Task

For Android sample project please see this repo - https://github.com/NativeScript/sample-android-background-services

A sample project demonstrating how NativeScript application can execute JavaScript code while the app is in background state. On applicationDidEnterBackground the app starts a custom background task. It uses the NSTimer API to print a console message on a fixed time interval. To start the task press the Home button in order to move the app to the background.

Since iOS doesn't allow a general-purpose background task to run forever, such a task will be suspended by the operating system after approximately 3 minutes. In some special cases your task is allowed to run longer, but you need to use UIBackgroundModes in your Info.plist file to specify the intent of your task (which automatically makes it not general-purpose).

Running the sample

    git clone https://github.com/NativeScript/sample-ios-background-execution.git
    cd sample-ios-background-execution
    npm install
    tns run ios
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].