0

I am creating and app similar to uber but instead of creating two separate apps i am placing both the driver and passenger activities in the same app... After the driver declines a passenger request a notification is sent to the driver informing them that the driver has decline the request... This notification generates the error:

E/UncaughtException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

in the passenger app compliments of the line

LatLng customer_location = new Gson().fromJson(remoteMessage.getNotification().getBody(),LatLng.class);

Gson File

public interface IFCMService {
@Headers({
        "Content-Type:application/json",
        "Authorization:key=xxx"
})
@POST("fcm/send")
Call<FCMResponse> sendMessage(@Body Sender body);

}

MyFirebaseMessagingService

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {

        Log.d("EARLYBIRD", remoteMessage.getNotification().getBody());

        // Include Latitude and Longitude in firebase message
        LatLng customer_location = new Gson().fromJson(remoteMessage.getNotification().getBody(),LatLng.class);

        Intent intent = new Intent(getBaseContext(), CustomerCall.class);
        intent.putExtra("lat",customer_location.latitude);
        intent.putExtra("lng",customer_location.longitude);
        intent.putExtra("customer",remoteMessage.getNotification().getTitle());
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        startActivity(intent);
    }
}
Community
  • 1
  • 1
  • what is the JSON you are getting back from Firebase? – user2340612 Mar 17 '18 at 16:22
  • I am sending a notification form driver to the customer that also includes the latitude and longitude.... json should be a object it is being receive as a string... – user293375 Mar 17 '18 at 17:09
  • Possible duplicate of [Why am I getting a JsonSyntaxException: Expected BEGIN\_ARRAY but was STRING here?](https://stackoverflow.com/questions/29793314/why-am-i-getting-a-jsonsyntaxexception-expected-begin-array-but-was-string-here) – user2340612 Mar 17 '18 at 17:40

0 Answers0