2016-01-13 30 views
1

我想定製codenameone在android/iOS設備上收到的推送通知。Codename one:如何定製接收推送通知

目前,我正在使用notifyStatusBar方法,但我不知道要在Hashtable參數中放置什麼。

Display.getInstance().notifyStatusBar("Test notification", "Mobile", value, true, false, new Hashtable()); 

回答

1

notifyStatusBar只是一個顯示在您的應用程序(僅適用於支持它的平臺)運行設備的狀態欄的警報方法。

推送通知是代碼名稱1中的一項專業功能,它允許您從一個設備上運行的應用程序向另一個設備發送遠程通知,或者從Web發送到您的應用程序。不要混淆本地通知。

如果你需要一個本地通知,你可以這樣做:

LocalNotification n = new LocalNotification(); 
n.setId("demo-notification"); 
n.setAlertBody("It's time to take a break and look at me"); 
n.setAlertTitle("Break Time!"); 
n.setAlertSound("beep-01a.mp3"); 

Display.getInstance().scheduleLocalNotification(
    n, 
    System.currentTimeMillis() + 10 * 1000, // fire date/time 
    LocalNotification.REPEAT_MINUTE // Whether to repeat and what frequency 
); 

源上方是this blog一部分。

,您可以按照有關如何在代號爲一個創建推送通知this tutorial,如果這就是你要找的內容,並瞭解最新更改的推送通知herehere

順便說一句,您發佈的方法以上已被棄用。

+0

現在我可以從服務器網站發送通知給應用程序,但我想處理通知顯示的方式。我認爲LocalNotification不適合我的情況。 – Adnane17

+0

在哪個平臺上?請注意,用戶可以在iOS設備上顯示通知的方式。 – Diamond

+0

現在我正在測試Android平臺。你說方法「notifyStatusBar」已被棄用,那麼我應該使用哪種方法? – Adnane17