I'm building two apps, one for booking a service and one for the managers to respond to the services requested by the clients, as soon as a booking is made it has to detect the location and according to that it has to send the order notification to the nearest manager. How do I do this. I'm using Google maps api to search the nearest manager and that piece of code is working fine. But I'm unable to integrate the push notifications as I have no idea about it. How do I use my server to do this and once the notifications is sent, if the manager doesn't respond, then I want the server to send the message again after 30 minutes. Please help me.. Thank you!
I'm facing the same problem, so I will write my steps below.
1) As google says Firebase Cloud Messaging (FCM) is the new version of GCM.
. So if you are starting with a new app, use Firebase Cloud Messaging instead.
You will need:
A device running Android 2.3 (Gingerbread) or newer, and Google Play services 9.4.0 or newer
The Google Play services SDK from the Android SDK Manager Android Studio 1.5 or higher
2) Create a Firebase project or import existing one and follow the setup steps
1) To send a message to a specific device, you need to know that device's registration token. When you need to retrieve the current token, call FirebaseInstanceID.getToken()
. Also don't forget to implement onTokenRefreshcallback
. The onTokenRefreshcallback
fires whenever a new token is generated.
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
// If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the
// Instance ID token to your app server.
sendRegistrationToServer(refreshedToken);
}
2) After you've obtained the token, you can send it to your app server and try to send some messages.
That's in the short all you will find in documentation. Hope that it will help someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With