Skip to content

Updated iOS alert object to display title and body detail #735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* _Contributing to this repo? Add info about your change here to be included in next release_
* Fix: NaN displayed when filter input is empty or negative number (#749), thanks to [Miguel Serrrano](https://github.com/miguel-s)
* Fix: Addresses issue related to displaying iOS alert object containing title and body keys (#539), thanks to [Robert Martin del Campo](https://github.com/repertus)

### 1.1.0

Expand Down
18 changes: 16 additions & 2 deletions src/dashboard/Push/PushDetails.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ const EXP_STATS_URL = 'http://docs.parseplatform.org/ios/guide/#push-experiments
let getMessage = (payload) => {
if(payload) {
let payloadJSON = JSON.parse(payload);
return payloadJSON.alert ? payloadJSON.alert : payload;
if (payloadJSON.alert.body) {
Copy link
Contributor

@natanrolnik natanrolnik Jun 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to check the type of payloadJSON.alert, like in the other changed file? Also, in case there is a body, could you also add the title?

Copy link
Contributor Author

@repertus repertus Jun 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@natanrolnik - So under PushDetails if an alert object contains title and body, would you like me to show both the title and message just below the title in smaller font size?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be ideal! Do you think you can do it? I think it makes sense to do it the best way we can if you are already touching these files.

And did you see my question? Don't we need to check the type of payloadJSON.alert, or it will always be an object here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@repertus Robert, we wanted to make a release in the next few days - if you could do these changes, it will enter in the next release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@natanrolnik,

Sorry I took so long to circle back, but I've been tied up. I was able to modify the component to display both the title and the body as part of detail by checking the existance of an tyeof objective to keep consistant as per your observation. Here is a screenshot.
screen shot 2017-08-09 at 8 29 55 am

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@natanrolnik,

Can you outline why the build is failing in Travis.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@repertus Sorry, I was afk for a few hours. Thanks for working on it!

return payloadJSON.alert.body;
} else if (payloadJSON.alert) {
return payloadJSON.alert;
} else {
return payload;
}
}
return '';
}
Expand Down Expand Up @@ -461,6 +467,7 @@ export default class PushDetails extends DashboardView {
let isMessageType = pushDetails.exp_type === 'message';
let res = null;
let prevLaunchGroup = null;
let alert = getMessage(pushDetails.get('payload'));

if (pushDetails && pushDetails.experiment_push_id) {
prevLaunchGroup = (
Expand Down Expand Up @@ -512,7 +519,14 @@ export default class PushDetails extends DashboardView {
<div>
<div className={styles.groupHeader}>
<div className={styles.headerTitle}>MESSAGE SENT</div>
<div className={styles.headline}>{getMessage(pushDetails.get('payload'))}</div>
{
(typeof alert === 'object') ?
<div>
<div className={styles.headline}>{alert.title}</div>
<div className={styles.headline}>{alert.body}</div>
</div>:
<div className={styles.headline}>{alert}</div>
}
<div className={styles.subline}>
{getSentInfo(pushDetails.get('pushTime'), pushDetails.get('expiration'))}
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/dashboard/Push/PushIndex.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ let getPushName = (pushData) => {
if (typeof payload === 'object') {
if (typeof payload.alert === 'string') {
return payload.alert;
} else if (typeof payload.alert === 'object' && payload.alert.title !== undefined) {
return payload.alert.title;
}
return payload.alert ? JSON.stringify(payload.alert) : JSON.stringify(payload);
} else {
Expand Down