Delphi 10.1 Android如何获取Firebase设备令牌

时间:2016-11-30 12:43:51

标签: android delphi

我试过了:

APushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM);
APushService.AppProps[TPushService.TAppPropNames.GCMAppID] := '"mobilesdk_app_id" '; // my "mobilesdk_app_id" from google-services.json
AServiceConnection := TPushServiceConnection.Create(APushService);
AServiceConnection.Active := True;
AServiceConnection.OnChange := OnServiceConnectionChange;
AServiceConnection.OnReceiveNotification := OnReceiveNotificationEvent;

ADeviceID := APushService.DeviceIDValue[TPushService.TDeviceIDNames.DeviceID];
AdeviceToken := APushService.DeviceTokenValue[TPushService.TDeviceTokenNames.DeviceToken];

ADeviceID正确显示,AdeviceToken空白。

1 个答案:

答案 0 :(得分:2)

因为:

APushService.AppProps[TPushService.TAppPropNames.GCMAppID] := '"mobilesdk_app_id" 

错误,此属性与 mobilesdk_app_id 无关。它与 SENDER ID 相关。此值可在设置 - >下找到云消息 - >发件人ID 。一旦你输入了这个值,你就会收到令牌。