Skip to content

[Notifier] Add Expo bridge #42414

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 1 commit into from
Oct 28, 2021
Merged

[Notifier] Add Expo bridge #42414

merged 1 commit into from
Oct 28, 2021

Conversation

zairigimad
Copy link
Contributor

@zairigimad zairigimad commented Aug 6, 2021

Q A
Branch? 5.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets no ticket
License MIT

Expo makes implementing push notifications almost too easy. All the hassle with native device information and communicating with APNs (Apple Push Notification service) or FCM (Firebase Cloud Messaging) is taken care of behind the scenes, so that you can treat iOS and Android notifications the same, saving you time on the front-end, and back-end!

this PR will add the support of Expo Notification as a bridge to Symfony

screenshot from a real application build with expo

2DA98E58-4F0A-4A89-B6CB-937878E00E4A

✏️ this is a work in progress I would love to hear your feedbacks to improve it.

@carsonbot
Copy link

Hey!

To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done?

Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review.

Cheers!

Carsonbot

@zairigimad zairigimad marked this pull request as ready for review August 6, 2021 19:40
@zairigimad zairigimad requested a review from OskarStark as a code owner August 6, 2021 19:40
@zairigimad zairigimad force-pushed the expo-notifier branch 3 times, most recently from 854617f to 383b6da Compare August 6, 2021 19:48
@norkunas
Copy link
Contributor

norkunas commented Aug 6, 2021

Maybe push channel #39402 should be merged before? :)

@zairigimad zairigimad force-pushed the expo-notifier branch 3 times, most recently from d3edebf to 71f895b Compare August 6, 2021 21:44
@OskarStark OskarStark added this to the 5.4 milestone Aug 7, 2021
@zairigimad zairigimad force-pushed the expo-notifier branch 2 times, most recently from 0eab128 to fbf4bd2 Compare August 7, 2021 19:12
$jsonContents = 0 === strpos($contentType, 'application/json') ? $response->toArray(false) : null;

if (200 !== $statusCode) {
$errorMessage = $jsonContents ? $jsonContents['error']['message'] : $response->getContent(false);
Copy link
Member

Choose a reason for hiding this comment

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

what if $jsonContents['error']['message'] does not exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if i understand well the official documentation https://docs.expo.dev/accounts/programmatic-access/#personal-account-personal-access-tokens
normally when the status code is not OK we are in error mode for expo and we should have the error payload as explained in the article.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, you are right I spent some time testing the possibles cases, I found out that when it's 401 the response is different, I updated this part of handling the exception.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

random notes :)

@zairigimad zairigimad force-pushed the expo-notifier branch 5 times, most recently from addb8fa to a15efa8 Compare August 9, 2021 17:51

throw new TransportException('Unable to post the Expo message: '.$errorMessage, $response);
}
if (isset($jsonContents['error']['message'])) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to get a 200 with errors in the response? If not, the 1st check is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right I did revisit the API documentation again, I will delete this check the first one is enough. good catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@zairigimad zairigimad force-pushed the expo-notifier branch 2 times, most recently from cc39c71 to 1ba96a7 Compare September 21, 2021 11:42
@fabpot
Copy link
Member

fabpot commented Oct 19, 2021

Now that the push channel feature has been merged (see #39402), I think this PR can be finished. @zairigimad Do you have time to update the code?

@zairigimad
Copy link
Contributor Author

Now that the push channel feature has been merged (see #39402), I think this PR can be finished. @zairigimad Do you have time to update the code?

Yes, I will take some time today to update the code.

@zairigimad zairigimad force-pushed the expo-notifier branch 2 times, most recently from cd64196 to ed8f2fa Compare October 19, 2021 12:21
@zairigimad zairigimad requested a review from OskarStark October 19, 2021 14:29
@zairigimad
Copy link
Contributor Author

@fabpot I updated the code with the new PushChannel.

@@ -0,0 +1,22 @@
Expo Notifier
=================
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
=================
=============

@fabpot
Copy link
Member

fabpot commented Oct 28, 2021

Thank you @zairigimad.

@fabpot fabpot merged commit e399e9d into symfony:5.4 Oct 28, 2021
@fabpot
Copy link
Member

fabpot commented Oct 28, 2021

@zairigimad Can you create a PR on symfony/recipes like done for other notifiers?

@zairigimad
Copy link
Contributor Author

@zairigimad Can you create a PR on symfony/recipes like done for other notifiers?

Yes i will check how it’s done and do a PR asap

This was referenced Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants