2013-08-02 66 views
0

我收到我的android設備上的推送通知,但堅持讓它使用任何插件或一些JS代碼保存。如何在本地存儲sencha touch中保存解析推送通知消息?

以下是我在活動的onCreate

Parse.initialize(this, "2dkgSPO0Pklpuo3yVjY8KeUQKtNWwpitTFMlMdHF", "O4ViBkcJRo9MrCeiKF49czzVrc7htMcYfdySKFTF"); 
    PushService.setDefaultPushCallback(this, MyPhoneGapActivity.class); 
    ParseInstallation.getCurrentInstallation().saveInBackground(); 

修改下面的代碼是我在清單文件所做的更改:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 

<service android:name="com.parse.PushService" /> 
    <receiver android:name="com.parse.ParseBroadcastReceiver"> 
     <intent-filter> 
     <action android:name="android.intent.action.BOOT_COMPLETED" /> 
     <action android:name="android.intent.action.USER_PRESENT" /> 
     </intent-filter> 
    </receiver> // in application tag 

回答

0

你應該使用本地存儲商店,然後添加一個模型,當你得到一個推和同步商店:

Ext.define('MyApp.model.Notification', { 
    extend: 'Ext.data.Model', 

    config: { 
     fields: [ 
      // notification fields 
     ], 
     proxy: { 
      type: 'localstorage', 
      id: 'notifications' 
     } 
    } 
});  

Ext.define('MyApp.store.Notification', { 
    extend: 'Ext.data.Store', 

    config: { 
     model: 'MyApp.store.Notification', 
     autoSync: true, 
     autoLoad: true 
    } 
}); 


receiveNotification: function(notif) 
{ 
    var store = Ext.getStore('Notifications'), 
     record = //create your model from notif 

    store.sync(); 
} 
+0

有沒有問題,商店和型號創建,但問題是如何獲得這個函數在收到通知時調用。我目前使用Parse和PhoneGap來接收推送通知 –

+0

那麼你是否真的收到通知?如果是這樣,請發佈您的代碼。 – kevhender

+0

添加了有問題的代碼。請看一下,讓我知道我應該如何收到通知的意圖。 –