I'm really trying to use AppGameKit without my old custom interpreter to save me headaches (but it's creating more!). The push notification icon is a white square. I see in my old android player/interpreter set up I had added extra code to get the notification icon correct.
This white icon looks very unprofessional. The requirement for a white push notification on Android has been present since Android 5 (2014) it's now 2 years later and we're almost on Android 7. It would be wonderful if AppGameKit could add the ability to use a notification icon. The Java code is very simple and you'd just have to place the icon in the drawable directory.
Here's the code:
@Override
public void onMessage(Context context, Intent intent)
{
Log.i("WS onMessage" , "isRunning = " + String.valueOf(AGKHelper.isRunning));
if (!AGKHelper.isRunning)
{
String message = intent.getStringExtra("message");
String title = intent.getStringExtra("title");
//NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
//Intent intent2 = new Intent(this, NotificationReceiver.class);
//PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent2, 0);
Intent intent2 = new Intent(this, NativeActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent2, 0);
CharSequence from = title;
/*
Notification notif = new Notification(
R.drawable.icon,
message,
System.currentTimeMillis());
notif.setLatestEventInfo(this, from, message, pIntent);
*/
Bitmap largeIcon = null;
//BufferedInputStream buf = null;
try
{
//buf = new BufferedInputStream(getResources().getDrawable(com.naplandgames.wordspionage.R.drawable.icon));
//largeIcon = BitmapFactory.decodeStream(buf);
//buf.close();
largeIcon = BitmapFactory.decodeResource(context.getResources(), com.naplandgames.wordspionage.R.drawable.icon);
}
catch (Exception ex)
{
Log.i("WS Push" , "exception with large icon");
ex.printStackTrace();
}
Notification notif = new NotificationCompat.Builder(context)
.setContentTitle(from)
.setContentText(message)
.setSmallIcon(com.naplandgames.wordspionage.R.drawable.notify)
.setContentIntent(pIntent)
.setAutoCancel(true)
.setLargeIcon(largeIcon)
.setDefaults(Notification.DEFAULT_SOUND | Notification.FLAG_AUTO_CANCEL)
.build();
notificationManager.notify(MY_NOTIFICATION_ID, notif);
}
}
Please note that this code also has some extra functionality to prevent notifications from showing while the app is in the foreground. This would also be a beneficial feature for AppGameKit apps to make them more professional.
PS - I'll give a Steam review if this is in the next build