请教,我想获取推送的消息,然后再App内部状态栏使用,怎么弄

feng2017
2017-12-15 03:41 1.6k 0

我想获取推送的消息,然后再App内部状态栏使用,求指教

using UnityEngine;
using System.Collections;
using JPush;
using System.Collections.Generic;
using System;
using UnityEngine.UI;

#if UNITY_IPHONE
using LitJson;
#endif

public class Notice : MonoBehaviour {

    string str_unity = "";
    int callbackId = 0;


    void Start () {
        gameObject.name = "Main Camera";
        JPushBinding.Init(gameObject.name);
        JPushBinding.SetDebug(true);
    }

    void Update () {

    }

    void OnReceiveMessage(string jsonStr)
    {
        //Debug.Log("recv----message-----" + jsonStr);
        gameObject.GetComponent<Text>().text = "2222222222";
        //str_unity = jsonStr;
    }

    void OnReceiveNotification(string jsonStr)
    {
        //Debug.Log("recv---notification---" + jsonStr);
        gameObject.GetComponent<Text>().text = "3333333333";
    }
}

2个回答

热门排序
  • 事件监听方法所在脚本挂载的 GameObject 要和初始化时设置的 GameObject 名称一致。 比如,你这里代码里初始化时设置的是 "Main Camera",那脚本就需要挂载在 "Main Camera" 上。或者选择把 "Mai 展示全部
  • 在iOS设备上还是Android 设备上? 收到消息会走 获取方法,即可取到内容。 iOS需要点击通知栏,也可以使用 Message自定义消息,前台接受,不展示 https://community.jiguang.cn/article/10 展示全部