我有一个可以用来打电话的应用程序。当一个用户想要呼叫另一个用户时,我的服务器将此json发送到“ https://fcm.googleapis.com/v1/projects/MyProject/messages:send
{
"validate_only":false,
"message": {
"data": {
"SomeData":"123"
},
"notification":null,
"android": {
"collapse_key":null,
"priority":"HIGH",
"ttl":"60s",
"restricted_package_name":null,
"data": {
"SomeData":"123"
},
"notification":null
},
"webpush": {
"headers": {
"Urgency":"high"
},
"data":null,
"notification":null,
"fcm_options":null
},
"apns": {
"headers": {
"apns-priority":"10"
},
"payload":null
},
"token":"cU4RS3R142s:APA91bF6fDme6mxw9FcocLvXYepkpqYHbctZ0arEw43-6uhZCglyQ9qfndfmeeNE9oALkpzQ7boh47unQRoTMSUhy6ynddo6r8RcgYl9yuj07NCgDcSUfY4__YNSxpeGziXqQnDzGMZx",
"topic":null,
"condition":null
}
}
当应用程序处于前台状态以及从最近的列表中将其刷出几分钟后,它可以正常工作。但是大约20分钟后,FirebaseMessagingService.OnMessageReceived
不再被呼叫,我正在logcat中得到它。
01-23 10:19:59.670: I/FirebaseInitProvider(7162): FirebaseApp initialization successful
01-23 10:19:59.717: I/MyTag(7162): Application: OnCreate
01-23 10:19:59.896: W/ActivityManager(1398): Background start not allowed: service Intent { act=com.google.firebase.MESSAGING_EVENT pkg=com.companyname.MyApp.Android cmp=com.companyname.MyApp.Android/com.companyname.myapp.android.notificationservice (has extras) } to com.companyname.MyApp.Android/com.companyname.myapp.android.notificationservice from pid=7162 uid=10179 pkg=com.companyname.MyApp.Android
01-23 10:19:59.897: E/FirebaseInstanceId(7162): Error while delivering the message: ServiceIntent not found.
这是我的应用程序的代码
public override void OnCreate()
{
base.OnCreate();
WriteLog("Application: OnCreate");
InitializePlayService();
}
private void InitializePlayService()
{
FirebaseApp.InitializeApp(this);
MyFirebaseIDService.SendRegistrationToServer(FirebaseInstanceId.Instance.Token);
}
我如何使其工作?