Позвоните код уведомления в API успеха, посмотрите
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pushnotifications);
URL obj = null;
try {
obj = new URL("https://gekon.technologypark.cz/api/v1/notification/demo/8");
HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("ApiSecret", LoginInfo.ApiSecret);
conn.connect();
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
StringBuilder sb = new StringBuilder();
String output;
while ((output = br.readLine()) != null)
sb.append(output);
JSONObject jsonObj = new JSONObject(sb.toString());
String notifText=(String) jsonObj.get("data");
Log.d("log","PUSH NANI"+notifText);
showNotification(notiftext)
} catch (Exception e) {
e.printStackTrace();
Log.d("log","PUSH CATCG"+e);
}
}
вот метод для показа уведомления после успешного вызова API.
public void showNotification(String message){
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher_background) // notification icon
.setContentTitle("Notification!") // title for notification
.setContentText(message); // message for notification
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationManager.notify().
mNotificationManager.notify(001, mBuilder.build());
}
Надеюсь, это поможет вам !!