0

I'm having an issue (an exception) when I navigate to another page after using the nativescript-contacts plugin. The app is built using the tns-template-drawer-navigation-ts template. Everything works fine until I access the phone's contacts and return, and then try to switch to another page using the drawer navigation. The problem is that the Frame stack is empty after I return from the Contacts screen and the topmost().navigate function calls into Frame and, since the Frame stack is empty (array length = 0), "undefined" is returned. Below are relevant sections of the code from the Chrome Debugger. Is this a core, plugin bug or am I supposed to be pushing a frame on the stack before or after I call getContact.

I've updated to tns 5.3.1, updated tns and tried to solve the problem in my own code but the code is failing in core nativescript.

My Code:

export function onGetContact(args: EventData) {
    Permissions.requestPermissions([android.Manifest.permission.GET_ACCOUNTS,
    android.Manifest.permission.READ_CONTACTS,],
        "Permission to access your contacts is requested")
        .then(() => {
            Contacts.getContact()
                .then((args: GetContactResult) => {
                    /// Returns args:
                    /// args.reponse: "fetch"
                    /// args.data: Generic cross platform JSON object, null if no contacts were found.
                    logContact(args);
                    storeContact(args.data);

                }, function (err) {
                    console.log("Error: " + err);
                })
        });
}

The contact is returned fine and the current page works. The issue occurs when I try to navigate away from the current page using a drawer tap which should take me to one of my other pages. So it seems the "Contact" display is clearing the frame array (frame stack).

Craig Jacobs
  • 5
  • 1
  • 3
  • From Debugger: function topmost() { return frame_stack_1.topmost(); } exports.topmost = topmost; frameStack: Array(0) <-- Here is the problem length: 0 __proto__: Array(0) Exceptions: global.__onUncaughtError = function (error) { events.notify({ eventName: exports.uncaughtErrorEvent, object: app, android: error, ios: error, error: error }); }; global.__onDiscardedError = function (error) { events.notify({ eventName: exports.discardedErrorEvent, object: app, error: error }); }; – Craig Jacobs Apr 03 '19 at 18:31
  • Contacts list is a native activity, having that displayed wouldn't justify you have a Frame in your app. Unless you have declared a `` element explicitly in your project, there won't be a frame created. – Manoj Apr 03 '19 at 19:09
  • Everything works until I display the contact list by calling the Contacts.getContact() function. If I never call Contacts.getContact(), there is no exception thrown regardless of how many times I switch pages using the drawer navigation. However, after I call Contacts.getContact(), then the very next time I use the drawer navigation, the code fails because there is no "topmost" and an undefined is returned from the Frame code. So, it seems to me that something is clearing the Frame stack when Contacts.getContact() is called. – Craig Jacobs Apr 05 '19 at 00:24
  • Can you share the sample project where the issue can be reproduced? – Manoj Apr 05 '19 at 06:33
  • I'll create a test project and see if I can reproduce the problem. Thanks for your help, Manoj! – Craig Jacobs Apr 06 '19 at 13:55
  • You're correct, nothing to do with the contacts page. I installed a clean copy of the template app and it happens when I have the app open, then press the "overview" button, bring another app to foreground, then bring the nativescript app to foreground and select any navigation page. Using "tns-template-drawer-navigation-ts" – Craig Jacobs Apr 08 '19 at 14:48

1 Answers1

0

Ok, Nikolay Tsonev gave me the answer, it was my fault, the "Don't keep activities option" was enabled in Dev Options. After disabling it, everything works fine when I switch between apps.

Craig Jacobs
  • 5
  • 1
  • 3