MOBILE-2915 ios: Fix shared files treated twice in iOS 12

main
Dani Palou 2019-03-26 16:13:23 +01:00
parent b3663e591c
commit 63cfc0604a
1 changed files with 13 additions and 1 deletions

View File

@ -44,15 +44,27 @@ export class CoreSharedFilesModule {
delegate.registerHandler(handler);
if (platform.is('ios')) {
let lastCheck = 0;
// Check if there are new files at app start and when the app is resumed.
helper.searchIOSNewSharedFiles();
platform.resume.subscribe(() => {
// Wait a bit to make sure that APP_LAUNCHED_URL is treated before this callback.
setTimeout(() => {
if (Date.now() - lastCheck < 1000) {
// Last check less than 1s ago, don't do anything.
return;
}
lastCheck = Date.now();
helper.searchIOSNewSharedFiles();
}, 200);
});
eventsProvider.on(CoreEventsProvider.APP_LAUNCHED_URL, (url) => {
if (url && url.indexOf('file://') === 0) {
// We received a file in iOS, it's probably a shared file. Treat it.
lastCheck = Date.now();
helper.searchIOSNewSharedFiles(url);
}
});