Commit 30d54fa0 authored by Simon MacDonald's avatar Simon MacDonald
Browse files

Issue #75: Implement Big Picture Style for Android

parent eddf785c
Loading
Loading
Loading
Loading
+17 −0
Changes for README.md: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -369,6 +369,23 @@ This will produce the following notification in your tray:

If your users clicks on the main body of the notification your app will be opened. However if they click on either of the action buttons the app will open (or start) and the specified JavaScript callback will be executed. In this case it is `app.emailGuests` and `app.snooze` respectively.

### Picture Messages

Perhaps you want to include a large picture in the notification that you are sending to your users. Luckily you can do that too buy sending the following JSON from GCM.

```javascript
{
	title:"Big Picture", 
	message: "This is my big picture message", 
	style: "picture",
	summaryText: "The internet is built on cat pictures"
}
```

This will produce the following notification in your tray:

![2015-08-25 16 08 00](https://cloud.githubusercontent.com/assets/353180/9472260/3655fa7a-4b22-11e5-8d87-20528112de16.png)

## iOS Behaviour

### Sound
+16 −1
Changes for src/android/com/adobe/phonegap/push/GCMIntentService.java: 16 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public class GCMIntentService extends GCMBaseIntentService {

    private static final String LOG_TAG = "PushPlugin_GCMIntentService";
    private static final String STYLE_INBOX = "inbox";
    private static final String STYLE_PICTURE = "picture";
    private static final String STYLE_TEXT = "text";
    private static ArrayList<String> messageList = new ArrayList();

@@ -238,7 +239,6 @@ public class GCMIntentService extends GCMBaseIntentService {
    }

    private void setNotificationMessage(Bundle extras, NotificationCompat.Builder mBuilder) {
        NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle();
        String message = getMessageText(extras);

        String style = extras.getString("style", STYLE_TEXT);
@@ -265,8 +265,23 @@ public class GCMIntentService extends GCMBaseIntentService {

                mBuilder.setStyle(notificationInbox);
            }
        } else if (STYLE_PICTURE.equals(style)) {
            setNotification("");

            NotificationCompat.BigPictureStyle bigPicture = new NotificationCompat.BigPictureStyle();
            bigPicture.bigPicture(getBitmapFromURL(extras.getString("picture")));
            bigPicture.setBigContentTitle(extras.getString("title"));
            bigPicture.setSummaryText(extras.getString("summaryText"));

            mBuilder.setContentTitle(extras.getString("title"));
            mBuilder.setContentText(message);

            mBuilder.setStyle(bigPicture);
        } else {
            setNotification("");

            NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle();

            if (message != null) {
                mBuilder.setContentText(Html.fromHtml(message));