我希望能够使用retrofit
从安卓设备向另一个设备发送fcm通知
。
我尝试了以下方法,但是:
public interface ApiInterface {
@Headers("Authorization : key=AAAA4Ubio1Q:APA91bGWkw84b1XX2nnnOKn8MO25U2giLRXXXTUkXidojFluZk_qKXXXlS27oMZZV5goTQdwRtpdmvI1iAPRZZDNKz6c-mpU6nvHZJ-Jg9f1fQ5NdttftqUpqwAkObLEEX26VFDDbXN8")
@POST("fcm/send")
Call<ResponseBody> sendChatNotification(@Field("to") String token,@Body RequestNotificaton requestNotificaton);
}
我遇到了这个错误。
java.lang.IllegalArgumentException: Unexpected char 0x20 at 13 in header name: Authorization
at okhttp3.Headers$Builder.checkNameAndValue(Headers.java:330)
at okhttp3.Headers$Builder.add(Headers.java:288)
at retrofit2.ServiceMethod$Builder.parseHeaders(ServiceMethod.java:329)
at retrofit2.ServiceMethod$Builder.parseMethodAnnotation(ServiceMethod.java:270)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:175)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy0.sendChatNotification(Unknown Source)
at com.rudruam.v2chat.Activity.ChatActivity.sendNotificationToPatner(ChatActivity.java:288)
at com.rudruam.v2chat.Activity.ChatActivity.access$400(ChatActivity.java:94)
at com.rudruam.v2chat.Activity.ChatActivity$4.onClick(ChatActivity.java:227)
at android.view.View.performClick(View.java:6294)
at android.view.View$PerformClick.run(View.java:24770)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6499)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:442)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
我认为在Header
中有一个错误
,
注意:我看到了https://github.com/square/retrofit/issues/1153,但对我没有用。