2017-01-18 11 views
2

私は、毎朝午前8時に20分に起きてユーザーのジオロケーションに基づいてユーザーリマインダーを送信する必要があるIONIC2アプリを持っています。バックグラウンドジオロケーションを使用していてもしばらくしてからIONIC2 - アプリケーションが終了する

私は(ユーザの位置の変化を監視するためにIOSの重要な変更のAPIを使用しています)このプラグインを使用しています https://github.com/mauron85/cordova-plugin-background-geolocation

問題: 私はアプリや背景を閉じたときにアプリが殺されません。地理位置は私のためにしばらくの間働く。私は1時間までテストしました。しかし、私が翌朝目を覚ますと、IOSによってアプリが殺されたことがわかります。

アプリをバックグラウンドで実行し続ける別のプラグインがあることは知っていますが、私はAppStoreによってあなたのアプリが拒否されるという人からの苦情をたくさん読んでいます(実際にはプラグインに免責事項があります同様の効果もあります)。明日アプリを覚ますために

、私は単にここでのsetTimeout

setTimeout(function(){ 
     console.log('waking up'); 
     self.helper.scheduleLocalNotification('Hello World', 'Good Morning', 10, ""); 
     self.ionViewDidEnter(); 
    }, wakeupinMilliSeconds); 

を設定し、私のジオロケーションコードです:

setupBackGroundGeolocation(){ 
     let config = { 
       desiredAccuracy: 100, 
       stationaryRadius: 50, 
       distanceFilter: 100, 
       interval: 5000, 
       pauseLocationUpdates: false, 
       debug: false, // enable this hear sounds for background-geolocation life-cycle. 
       stopOnTerminate: false, // enable this to clear background location settings when the app terminates 
     }; 

     BackgroundGeolocation.configure((location) => { 
      console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude); 
      this.currentLocation.lat = location.latitude; 
      this.currentLocation.lng = location.longitude; 

      Promise.all([ 
        //I do some calculations here. 
       ]).then(d => { 
       // IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished, 
       // and the background-task may be completed. You must do this regardless if your HTTP request is successful or not. 
       // IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background. 
       BackgroundGeolocation.finish(); // FOR IOS ONLY 
       }); 
     }, (error) => { 
      console.log('BackgroundGeolocation error'); 
     }, config); 

     // Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app. 
     BackgroundGeolocation.start();  
     } 
+0

どのようなgeolocationプラグインをexaclyで使用していますか? –

答えて

0

私はこのプラグインを使用しますが、同じsymptonsを持っていません。何が間違っているのか分からなかった。エラーメッセージも手がかりもなかったが、アプリは数時間後に閉じたままだった。

非常に多くのコードバプラグインをインストールしてアンインストールした後に何かがうんざりしていたようです。今、アプリははるかに安定しています。私はプラットフォームを削除して追加しました。それは仕事をしているようだった。

0

私はionic2と性能について読んできました。非常に多くの理由のなかで、パフォーマンスの低下やクラッシュの可能性は、観測対象からの退会に関連していません。コンポーネントが破棄されたときにasync pipeと.unsubscribe observablesについて読むngOnDestroy

関連する問題