如何获取百度频道id



我们正在尝试集成百度SDK,并将其与后端的Azure通知中心一起使用。

在Android中,我们使用SDK:lib-techain-release-3.5.7.4

要获取设备的PushId,我们使用:

public class BaiduReceiver extends BroadcastReceiver {
private static final int TYPE_REGISTRATION = 1;
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (!PUSH_ACTION.equals(action)) {
return;
}
Bundle bundle = intent.getExtras();
int type = bundle.getInt("event_type", -1);
switch (type) {
case TYPE_REGISTRATION:
String uid = bundle.getString("push_uid");
break;
default:
break;
}
}
} 

这是有效的。此ID可用于从百度控制台发送推送通知。然而,当与Azure Notification Hub集成时,它还需要一个";信道ID";(参见https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.notificationhubs.baiduregistrationdescription?view=azure-dotnet(

我们如何在Android中获取此频道Id?

我们在使用百度的通知中心入门中有关于如何与百度集成的信息,特别是需要覆盖自定义PushMessageReceiver类的onBind方法。