首页 > 解决方案 > 在应用启动时从 Web 服务加载数据

问题描述

在我的 nativescript 应用程序中,我需要缓存从 Web 服务返回的数据。我应该在哪个确切位置调用从我的 Web 服务获取数据以将其存储在 appSettings 中?

如果我把它放在下面指定的位置:

applicationOn(launchEvent, function (args: ApplicationEventData) {
    if (args.android) {
        **WEB SERVICE CALL HERE**
    } else if (args.ios !== undefined) {
        // For iOS applications, args.ios is NSDictionary (launchOptions).
        console.log("Launched iOS application with options: " + args.ios);
    }
});

它根本不会被执行。没有错误或没有异常。

标签: androidangularnativescript

解决方案


推荐阅读