簡體   English   中英

Quickblox-如何將通知推送到Android和iOS平台?

[英]Quickblox - How can I push notification to both platform Android and iOS?

QBEvent是Quickblox提供來支持推送通知的類。 在Android平台上,我必須設置qbEvent.setPushType(QBPushType.GCM)在多個Android設備之間推送消息。

問題是我想為Android和iOS推送消息,但是我可以將這些行設置在一起。 qbEvent.setPushType(QBPushType.GCM)qbEvent.setPushType(QBPushType.APNS) 有什么解決辦法,請幫忙?

在此處輸入圖片說明

如果要向所有平台發送推送,則無需傳遞推送類型參數

解決方案N1(僅文本):

    QBEvent event = new QBEvent();
    event.setUserIds(userIds);
    event.setType(QBEventType.ONE_SHOT);
    event.setEnvironment(QBEnvironment.DEVELOPMENT);
    event.setNotificationType(QBNotificationType.PUSH);
    //
    event.setMessage("This is simple generic push notification!");

解決方案N2(帶有自定義參數):

    QBEvent event = new QBEvent();
    event.setUserIds(userIds);
    event.setType(QBEventType.ONE_SHOT);
    event.setEnvironment(QBEnvironment.DEVELOPMENT);
    event.setNotificationType(QBNotificationType.PUSH);
    //
    // generic push with custom parameters - http://quickblox.com/developers/Messages#Use_custom_parameters
    JSONObject json = new JSONObject();
    try {
      json.put("message", "This is generic push notification with custom params!");
      json.put("param1", "value1");
      json.put("ios_badge", "4"); // iOS badge value
    } catch (Exception e) {
      e.printStackTrace();
    }
    event.setMessage(json.toString());

我們的推送通知片段中的更多示例https://github.com/QuickBlox/quickblox-android-sdk/blob/master/snippets/src/main/java/com/sdk/snippets/modules/SnippetsPushNotifications.java#L217

以及文檔http://quickblox.com/developers/SimpleSample-messages_users-android#Universal_push_notifications

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM