2017-03-20 5 views
0

イオンアプリを起動してアプリ起動アイコンに通知バッジを取得しようとしています。 私が見た限りでは、イオンアプリが閉鎖されている(バックグラウンドではない)ので、誰もがいつもバックグラウンドで実行している私のイオンアプリを同期させるアンドロイドサービスを作成することができるかどうかを知っているアイコンバッジの更新? @Shibenは、これは私がそれを解決するために何をしたかで、尋ねたのでイオンアプリを同期する外部Androidサービス

は事前

答えて

0

でいただきありがとうございます。

  • https://firebase.google.comへコルドバ・プラグインfirebase

  • Go]をインストールし、firebaseプロジェクトを作成します(コンフィギュレーションのためのガイドを参照してください)

あなたapp.component.ts -Inはありません次のようなものです:

export class MyApp { 
rootPage:any = HomePage; 
firebase : any; 

constructor(public platform: Platform, 
        public statusBar: StatusBar, 
        public splashScreen: SplashScreen, 
        private _firebase: Firebase, 
        public alertCtrl: AlertController) { 

    platform.ready().then(() => { 
    (your things) 
    this.firebase = _firebase; 
    this.initFirebase(); 
    this.firebase.setBadgeNumber(0); 
}); 
} 

これは私のinitFirebase()です:

initFirebase(){ 

this.firebase.grantPermission(); 

this.firebase.onTokenRefresh() 
    .subscribe((token: string) => localStorage.setItem("pushToken", token)) 

this.firebase.onNotificationOpen() 
.subscribe((notification) => { 
    let alert = this.alertCtrl.create({ 
    title: 'New Notification', 
    subTitle: "Your notification", 
    buttons:['OK'] 
    }); 
    alert.present(); 
}); 
} 

-Inヨールのindex.htmlこのような何か(あなたがfirebaseからそれを得た)

<script src="https://www.gstatic.com/firebasejs/3.9.0/firebase.js"></script> 
<script> 
    // Initialize Firebase 
    var config = { 
    apiKey: "your key", 
    authDomain: "your domain", 
    databaseURL: "your url", 
    projectId: "your projid", 
    storageBucket: "your storagebucket", 
    messagingSenderId: "your messageid" 
    }; 
firebase.initializeApp(config); 
</script> 

を挿入し、私は長い時間前にこれをしなかったし、何かが変化するかもしれません。これは廃止されることもできますし、ベストプラクティスではないかもしれませんが、正しい方向にあなたを得ることができれば幸いです。

関連する問題