Skip to content

Commit 0f58451

Browse files
Support custom push notification icon in Xamarin android.
This brings us up to parity with the main Parse android SDK: https://parse.com/tutorials/android-push-notifications. Fixes #39.
1 parent e7049fc commit 0f58451

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Parse/Internal/ManifestInfo.cs

100644100755
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ public static int IconId {
107107
}
108108
return iconId;
109109
}
110+
}
111+
112+
private static int pushIconId = -1;
113+
public static int PushIconId {
114+
get {
115+
lock (mutex) {
116+
if (pushIconId == -1) {
117+
var customIcon = GetApplicationMetaData().GetInt("com.parse.push.notification_icon", -1);
118+
pushIconId = customIcon == -1 ? IconId : customIcon;
119+
}
120+
return pushIconId;
121+
}
122+
}
110123
}
111124

112125
private static Intent launcherIntent;

Parse/ParsePush.Android.cs

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public static void DefaultParsePushNotificationReceivedHandler(object sender, Pa
4444
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
4545
.SetContentTitle(new Java.Lang.String(title))
4646
.SetContentText(new Java.Lang.String(alert))
47-
.SetTicker(new Java.Lang.String(tickerText))
48-
.SetSmallIcon(ManifestInfo.IconId)
47+
.SetTicker(new Java.Lang.String(tickerText))
48+
.SetSmallIcon(ManifestInfo.PushIconId)
4949
.SetContentIntent(pContentIntent)
5050
.SetAutoCancel(true)
5151
.SetDefaults(NotificationDefaults.All);

0 commit comments

Comments
 (0)