Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android设备到设备推送通知响应200而不是201_Android_Firebase_Push Notification_Firebase Cloud Messaging - Fatal编程技术网

android设备到设备推送通知响应200而不是201

android设备到设备推送通知响应200而不是201,android,firebase,push-notification,firebase-cloud-messaging,Android,Firebase,Push Notification,Firebase Cloud Messaging,我正在尝试使用改型发送推送通知。我收到了回复200,但我想我需要201来完成这个过程。我不知道我做错了什么 API接口 public interface APIService { @Headers( { "Content-Type:application/json", "Authorization:key=AAAAx9xPkRc:APA91bF5I5RXf

我正在尝试使用改型发送推送通知。我收到了回复200,但我想我需要201来完成这个过程。我不知道我做错了什么

API接口

public interface APIService {
    @Headers(
            {
                    "Content-Type:application/json",
                    "Authorization:key=AAAAx9xPkRc:APA91bF5I5RXfNqUSQ_6YQb4Iyj5CMUrMMr4OZ0t3RMMEV5d532LlndjBT-all7elYPewv5_fSlco-n8rLa8Mhei3Or-MycCf509v4V92SPk_JOWUJd7UizJFg8etR3Z99B3"
            }
    )

    @POST("fcm/send")
    Call<MyResponse> sendNotification(@Body Sender body);

    class Client {

        private static Retrofit retrofit = null;

        public static Retrofit getClient(String url){
            if (retrofit == null){
                retrofit = new Retrofit.Builder()
                        .baseUrl(url)
                        .addConverterFactory(GsonConverterFactory.create())
                        .build();
            }
            return retrofit;
        }
    }


}
public class MyResponse {

    public int success;
}
MyResponse

public interface APIService {
    @Headers(
            {
                    "Content-Type:application/json",
                    "Authorization:key=AAAAx9xPkRc:APA91bF5I5RXfNqUSQ_6YQb4Iyj5CMUrMMr4OZ0t3RMMEV5d532LlndjBT-all7elYPewv5_fSlco-n8rLa8Mhei3Or-MycCf509v4V92SPk_JOWUJd7UizJFg8etR3Z99B3"
            }
    )

    @POST("fcm/send")
    Call<MyResponse> sendNotification(@Body Sender body);

    class Client {

        private static Retrofit retrofit = null;

        public static Retrofit getClient(String url){
            if (retrofit == null){
                retrofit = new Retrofit.Builder()
                        .baseUrl(url)
                        .addConverterFactory(GsonConverterFactory.create())
                        .build();
            }
            return retrofit;
        }
    }


}
public class MyResponse {

    public int success;
}
发送类

public class Sender {
    public DATAS data;
    public String to;

    public Sender(DATAS data, String to) {
        this.data = data;
        this.to = to;
    }
}
调用该方法

apiService = APIService.Client.getClient("https://fcm.googleapis.com/").create(APIService.class);
DATAS data = new DATAS("mizbah", "otpCode", "number", "userid");

        Sender sender = new Sender(data, token);
        apiService.sendNotification(sender)
                .enqueue(new Callback<MyResponse>() {
                    @Override
                    public void onResponse(Call<MyResponse> call, Response<MyResponse> response) {
                        if (response.code() == 200) {

                            if (response.body().success != 1) {
                                progress.dismiss();
                                Toast.makeText(context, response.body().success+"x", Toast.LENGTH_LONG).show();
                            } else {
                                confirmMessage(progress,context);

                            }
                        } else {
                            progress.dismiss();
                            Toast.makeText(context, "Error", Toast.LENGTH_SHORT).show();
                        }
                    }

                    @Override
                    public void onFailure(Call<MyResponse> call, Throwable t) {
                        progress.dismiss();
                        Toast.makeText(context, "2. সাময়িক সমস্যার জন্য দুঃখিত। অনুগ্রহ করে একটু পর আবার চেষ্টা করুন। ধন্যবাদ", Toast.LENGTH_SHORT).show();
                    }
                });
apiService=apiService.Client.getClient(“https://fcm.googleapis.com/)创建(APIService.class);
数据数据=新数据(“mizbah”、“otpCode”、“number”、“userid”);
发送方=新发送方(数据、令牌);
apiService.sendNotification(发件人)
.enqueue(新的回调函数(){
@凌驾
公共void onResponse(调用、响应){
if(response.code()==200){
if(response.body().success!=1){
进步。解散();
Toast.makeText(context,response.body().success+“x”,Toast.LENGTH_LONG.show();
}否则{
确认消息(进度、上下文);
}
}否则{
进步。解散();
Toast.makeText(上下文,“错误”,Toast.LENGTH_SHORT).show();
}
}
@凌驾
失败时公共无效(调用调用,可丢弃的t){
进步。解散();
Toast.makeText(上下文,“2。সাময়িক সমস্যার জন্য দুঃখিত। অনুগ্রহ করে একটু পর আবার চেষ্টা করুন। ধন্যবাদ", 吐司。长度(短)。show();
}
});
此方法工作正常,返回200,这意味着它可以与firebase通信,但要成功通知,我需要201作为回报。我找不到我的错误。正在寻求帮助。提前感谢