Esempio n. 1
0
 /** 收到推送通知时的回调方法 */
 @Override
 public void onReceive(String notificaitonName, HSBundle bundle) {
   // 供 HSGlobalNotificationCenter 功能参考,弹出 Toast 演示通知的效果
   String string =
       TextUtils.isEmpty(bundle.getString(SampleFragment.SAMPLE_NOTIFICATION_BUNDLE_STRING))
           ? "消息为空"
           : bundle.getString(SampleFragment.SAMPLE_NOTIFICATION_BUNDLE_STRING); // 取得 bundle 中的信息
   Toast toast = Toast.makeText(getApplicationContext(), string, Toast.LENGTH_LONG);
   toast.show();
 }
Esempio n. 2
0
  /**
   * 收到在线消息时被调用
   *
   * @param message 收到的在线消息,其 content 值由用户定制,可实现自己的通讯协议和交互逻辑
   */
  @Override
  public void onOnlineMessageReceived(HSOnlineMessage message) {
    HSLog.d(TAG, "onOnlineMessageReceived");

    // 弹出 Toast 演示示例在线消息的 content 消息体内容
    HSBundle bundle = new HSBundle();
    bundle.putString(
        SampleFragment.SAMPLE_NOTIFICATION_BUNDLE_STRING, message.getContent().toString());
    HSGlobalNotificationCenter.sendNotificationOnMainThread(
        SampleFragment.SAMPLE_NOTIFICATION_NAME, bundle);
  }