Closed irodeanu closed 5 years ago
getAvailableApps()
is used by the example app project and appears to return the expected data structure; if I modify the console.log()
statement in the example to this:
console.log("->getAvailableApps(): "+JSON.stringify(apps));
The output I get from an iPhone 7 running iOS 12.1 is this:
->getAvailableApps(): {"sygic":false,"taxis_99":false,"tomtom":false,"waze":false,"cabify":false,"gaode":false,"citymapper":false,"yandex":false,"here_maps":false,"navigon":false,"lyft":false,"transit_app":false,"maps_me":false,"apple_maps":true,"moovit":false,"uber":false,"baidu":false,"google_maps":false}
Please try building and running the example app project to confirm you get the same results.
On example project:
let apps = LaunchNavigator.getAvailableApps();
console.log(JSON.stringify(apps));
Response
{"_40":0,"_65":0,"_55":null,"_72":null}
OK, I think I see the problem here: the documentation for getAvailableApps()
is wrong.
It indicates that the result is returned synchronously, but because getAvailableApps()
is a native module function, the result is returned asynchronously via a Promise.
So try this:
LaunchNavigator.getAvailableApps()
.then((apps) => {
console.log("->getAvailableApps(): "+JSON.stringify(apps));
})
.catch((error) => {
console.error(error);
});
I'll update the documentation to make this clear and check if any other functions are wrongly documented as returning results sychronously.
Yes, it's working. Tank you.
Anyway, as an alternative solution, I tried that:
if (await Linking.canOpenURL('waze://')) { options.push(LaunchNavigator.APP.WAZE); }
OK, great.
I'll reopen this issue as I still need to fix the documentation because it's currently wrong. Can be closed once docs are updated.
I'm submitting a ... (check one with "x"):
Bug report
Environment information
0.55.3
10.14
Runtime issue
Related code:
Console output