How to show 'privacy' screen, when the app is sent to the background?



I am trying to implement a ‘privacy’ screen when the app is sent to the background/app drawer.
As seen with many ‘banking’ apps, a splash screen or different page is shown when the app is running in the background and the app drawer is opened.

In my app.component.ts I tried to trigger a navigation on the suspendEvent:

import { Component } from "@angular/core";
import { RouterExtensions } from "nativescript-angular/router";
import { on as applicationOn, suspendEvent, resumeEvent, ApplicationEventData } from "application";

  selector: "ns-app",
  templateUrl: "app.component.html"
export class AppComponent {
    private routerExtensions: RouterExtensions
  ) {

    applicationOn(suspendEvent, function(args: ApplicationEventData) {
        routerExtensions.navigate(["/privacyscreen"]); // page I want to show while the app is in the background

    applicationOn(resumeEvent, function(args: ApplicationEventData) {
        routerExtensions.back(); // Return to the page where user was before.


However, the navigation is being executed when the app is resumed.
Which means, when I send the app to the background and open the app drawer, I am still seeing the page where I left. And when the app is resumed, it navigates to "/privacyscreen" for a second and then the routerExtensions.back() triggers.

Any help regarding this is welcome!
Or if there is a better way to implement such feature, please let me know :slight_smile:


I think you have to customize the app delegate and use the applicationWillResignActive method to add a image or any content on top of your view so iOS takes a snapshot of same and uses it in app drawer. You have to remove that image or any content back when app resumes.

Alternatively you can add a observer for UIApplicationWillResignActive but haven’t tried that whether really works in this scenario.


@manojdcoder, hmm preferably I would like to achieve this without using any native methods/code.
But how would you do this for Android?


If you want something without much native code this should work for you. I haven’t done similar things in Android, so no idea as of now.


I’m not quite sure android has an equivalent but settings the sure flag prevents screenshots from everywhere.


@manojdcoder, thanks for your input!

Yes, I tried using the Android Flag_Secure before. This will cause the app to show a blank screen when viewed in the app drawer. However, as you also stated, this prevents any screenshots being taken from within the app.

I’ll consider it as a plan B, but will leave this topic ‘unsolved’ for now :slight_smile: