0
votes

Since switching to NS7 I can't get my iOS app to survive switching to the background. I'm implementing a solution whereby during a fetch the user needs to briefly switch app (2FA). I.e. the fetch starts, the user then goes to another app, pushing mine in the background and then comes back. The problem is that this breaks the fetch operation. Before I used the example here:

https://github.com/NativeScript/sample-ios-background-execution

But even after adding the missing @NativeClass() decorator I can't see the background task kicking in at any point (I've adjusted the main.ts as advertised and added the custom-app-delegate).

The official documentation is confusing:

https://docs.nativescript.org/core-concepts/ios-runtime/how-to/backgroundexecution

If I try to paste in the code then this.getNewData() goes nowhere and there is no mention of how this hooks into my service class that has that fetch method.

1

1 Answers

0
votes

After a lot of wrestling with code and trying tons of alternatives I found this:

https://gist.github.com/NathanWalker/2f8234fd900ceb9dac94b2b411d4960d

Turns out I got caught out by the "export" problem. So you need to define the class first and export it at the bottom of the file.