百度云推送怎么样接收通知消息

移动开发 码拜 7年前 (2017-05-05) 2800次浏览
最近刚刚接触百度云推送,按照安卓SDK开发文档一步步走,发现程序接收不到控制台发来的推送通知,本人的开发环境是Android Studio;
百度云推送怎么样接收通知消息
-控制台推送消息截图-
百度云推送怎么样接收通知消息
-虚拟机未收到推送通知-
百度云推送怎么样接收通知消息
-PushTestReceiver的代码截图-
百度云推送怎么样接收通知消息
-android studio的控制台显示绑定成功-
百度云推送怎么样接收通知消息
-Activity里的代码截图-
百度云推送怎么样接收通知消息
-相关的os和jar文件截图-
讨教一下过来人,是不是本人的os和jar文件配置错误?请各位帮帮忙!
解决方案

20

1. 首先需要在onBind绑定百度推送的账号。是需要在里面写逻辑处理的,而不是回调此函数就代表成功了

@Override
	public void onBind(Context context, int errorCode, String appid, String userId, String channelId, String requestId) {
		String responseString = "onBind errorCode=" + errorCode + " appid=" + appid + " userId=" + userId + " channelId=" + channelId + " requestId="
				+ requestId;
		Log.d(TAG, responseString);
		if (errorCode == 0) {
			// 绑定成功
			Log.e("NetWorkService", "开始百度推送服务绑定");
			Intent service = new Intent(context, NetworkService.class);
			service.putExtra("appid", userId);
			service.putExtra("channelId", channelId);
			service.putExtra("userId", userId);
			service.setAction(NetworkService.ServiceAction.ACTION_PUSH_BIND);
			context.startService(service);
		}
		// Demo更新界面展示代码,应用请在这里加入本人的处理逻辑
		// updateContent(context, responseString);
	}

2. 绑定成功之后,就可以通过官方后台,或你们的后台进行推送消息了。
3. 在onNotificationClicked 里面处理通知的点击事件。

@Override
	public void onNotificationClicked(Context context, String title, String description, String customContentString) {
		String notifyString = "通知点击 title="" + title + "" description="" + description + "" customContent=" + customContentString;
		Log.d(TAG, notifyString);

	}

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明百度云推送怎么样接收通知消息
喜欢 (0)
[1034331897@qq.com]
分享 (0)