0

私は{N} NG2アプリのeverlive APIをセットアップしようとしていますし、私はアプリを起動すると、私はTelerik Everlive API Nativescript Angular2セットアップ

const Everlive = require('./utils/everlive.all'); 

@Component({ 
    selector: "main", 
    template: "<page-router-outlet></page-router-outlet>" 
}) 
export class AppComponent implements AfterViewInit { 
    el: any; 

    constructor(private utils: Utils) { } 

    ngAfterViewInit() { 
     this.el = new Everlive({ 
      appId: Config.telerikAppId, 
      offlineStorage: true, 
      offline: { 
       syncUnmodified: true, 
       typeSettings: { 
        "ContentTypeName": { 
         "autoGenerateId": false 
        } 
       }, 
       storage: { 
        provider: Everlive.Constants.StorageProvider.FileSystem 
       } 
      }, 
      syncStart: this.startSync, 
      syncEnd: this.endSync 
     }); 

     // start 
     this.el.online(); 

     // track 
     connectivity.startMonitoring((newConnectionType: number) => { 
      switch (newConnectionType) { 
       case connectivity.connectionType.none: 
        console.log("Connection type changed to none."); 
        this.goOffline(); 
        break; 
       case connectivity.connectionType.wifi: 
        console.log("Connection type changed to WiFi."); 
        this.goOnline(); 
        break; 
       case connectivity.connectionType.mobile: 
        console.log("Connection type changed to mobile."); 
        this.goOnline(); 
        break; 
      } 
     }); 
    } 

    startSync() { 
     this.utils.showLoader(); 
    }; 

    endSync(syncInfo) { 
     this.utils.hideLoader(); 
     alert('Sync with server complete'); 
     console.log(syncInfo); 
    }; 

    goOffline() { 
     this.utils.confirmBox('No internet connection, switch to offline mode?', '', 'Yes', 'No') 
      .then((result) => { 
       if (result) { 
        this.el.offline(); 
       } else { 
        this.logout(); 
       } 
      }); 
    } 

    goOnline() { 
     this.utils.confirmBox('Internet connection detected, switch to online mode and sync data?', '', 'Yes', 'No') 
      .then((result) => { 
       if (result) { 
        this.utils.showLoader(); 
        this.el.online(); 
        this.el.sync(); 
       } else { 
        this.logout(); 
       } 
      }); 
    } 

    logout() { 

    } 
} 

を以下のように設定している、状態の束間を移動データがキャッシュされていることを期待しています。今、私はそれがキャッシュされたファイルシステムからデータを取得するために期待して私のラップトップ上でのWi-Fiをオフにする代わりに、私はzone.js

Unhandled Promise rejection: Response {_body: Error: The Internet connection appears to be offline., status: 200, ok: true, statusText: "", headers: Headers…} ; Zone: <root> ; Task: Promise.then ; Value: Response {_body: Error: The Internet connection appears to be offline., status: 200, ok: true, statusText: "", headers: Headers…} undefined 

からのエラーを参照してくださいこれは私がするときの応答をログインしたときに、私が見たものですsyncは、everlive SDKを使用して、インターネットに接続していないことを知らないようだし、要求を作るしようとし

Object {syncedItems: undefined, syncedToServer: 0, syncedToClient: 0, failedItems: undefined, error: undefined} 

答えて

関連する問題