Foren

Push Notification does not support FCM

Subhagnanam A, geändert vor 7 Jahren.

Push Notification does not support FCM

Junior Member Beiträge: 50 Beitrittsdatum: 25.02.16 Neueste Beiträge
For android users ,now google has moved from GCM to FCM ,so push notification is not working in liferay 6.2 GA3 version.
Is there any other solution.
thumbnail
Bruno Farache, geändert vor 7 Jahren.

RE: Push Notification does not support FCM

Liferay Master Beiträge: 603 Beitrittsdatum: 14.05.07 Neueste Beiträge
GCM still works, Subhagnanam. They haven't stopped the service.
Subhagnanam A, geändert vor 7 Jahren.

RE: Push Notification does not support FCM

Junior Member Beiträge: 50 Beitrittsdatum: 25.02.16 Neueste Beiträge
Does liferay will support FCM.Because the current liferay push notification works with GCM.
Subhagnanam A, geändert vor 7 Jahren.

RE: Push Notification does not support FCM (Antwort)

Junior Member Beiträge: 50 Beitrittsdatum: 25.02.16 Neueste Beiträge
hi i have done push notification using FCM.
here are the steps,
1)Create an account in "https://console.firebase.google.com" and Web API Key will get generated.
2)To send notification to multiple devices,create a topic in firebase.Refer the url(https://firebase.google.com/docs/notifications/ios/console-topics)for further details.
3)In server side create a hook plugin and call the service of particular application where you want to do notification and the FCM server side code in it.
4)Refer the below code for FCM notification,

public class FCMNotification{

public final static String AUTH_KEY_FCM = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
public final static String API_URL_FCM = "https://fcm.googleapis.com/fcm/send";

public void sendnotification(String string) {

String authKey = AUTH_KEY_FCM; // You FCM AUTH key
String FMCurl = API_URL_FCM;


try {
URL url = new URL(FMCurl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization","key="+authKey);
conn.setRequestProperty("Content-Type","application/json");

JSONObject json = new JSONObject();
json.put("to","/topics/news"); /*enter the topic name which you have created in console firebase*/
JSONObject info = new JSONObject();
info.put("Room", string); // Notification title
json.put("data", info);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(json.toString());
wr.flush();
conn.getInputStream();

} catch (IOException | JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }

}