2016-03-01 83 views
1

我正在嘗試使用official documentation將推送通知導入到Ionic 2應用程序中。在Ionic 2中使用Push

我已經包括了phonegap-plugin-push插件,但是當我插入的代碼,他們給你(包裹在一個平臺就緒功能),像這樣:

this.platform.ready().then(() => { 
    var push = Push.init({ 
     android: { 
      senderID: "12345679" 
     }, 
     ios: { 
      alert: "true", 
      badge: true, 
      sound: 'false' 
     }, 
     windows: {} 
    }); 

}); 

我只是得到了以下錯誤:

ORIGINAL EXCEPTION: ReferenceError: Push is not defined

是否還有其他我需要做的或者是否還沒有可能在Push Ionic 2應用程序中使用Push?

感謝您的任何幫助。

+0

我剛剛根據https://github.com/phonegap/phonegap-plugin-push文檔在最後使用了PushNotification。 –

+0

你是如何實現推送通知你可以給一些解釋或一步一步的過程來做到這一點 –

回答

2

You import從'ionic-native'推送?

import {Push} from 'ionic-native'; 
+0

雖然這可能在理論上回答這個問題,[這將是更可取的](/ meta.stackoverflow.com/q/8259)包括這裏的答案的基本部分,並提供參考鏈接。 – manetsus

+0

我發現答案非常完美。 –