-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: push permission prompt #101
Conversation
Pull request title looks good 👍! If this pull request gets merged, it will cause a new release of the software. Example: If this project's latest release version is All merged pull requests will eventually get deployed. But some types of pull requests will trigger a deployment (such as features and bug fixes) while some pull requests will wait to get deployed until a later time. This project uses a special format for pull requests titles. Expand this section to learn more (expand by clicking the ᐅ symbol on the left side of this sentence)...This project uses a special format for pull requests titles. Don't worry, it's easy! This pull request title should be in this format:
If your pull request introduces breaking changes to the code, use this format:
where
Examples:
Need more examples? Want to learn more about this format? Check out the official docs. Note: If your pull request does multiple things such as adding a feature and makes changes to the CI server and fixes some bugs then you might want to consider splitting this pull request up into multiple smaller pull requests. |
Hey, there @ami-aman 👋🤖. I'm a bot here to help you.
This pull request might still be allowed to be merged. However, you might want to consider make this pull request merge into a different branch other then This project uses a special format for pull requests titles. Expand this section to learn more (expand by clicking the ᐅ symbol on the left side of this sentence)...This project uses a special format for pull requests titles. Don't worry, it's easy! This pull request title should be in this format:
If your pull request introduces breaking changes to the code, use this format:
where
Examples:
Need more examples? Want to learn more about this format? Check out the official docs. Note: If your pull request does multiple things such as adding a feature and makes changes to the CI server and fixes some bugs then you might want to consider splitting this pull request up into multiple smaller pull requests. |
src/CustomerioTracking.tsx
Outdated
* @param options | ||
* @returns Success & Failure promises | ||
*/ | ||
static async showPromptForPushNotifications(options?: any) : Promise<any>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why any
is used for options parameter?
What about using a typescript interface
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. I used any
to prevent customer from importing another interface or config class. But this can be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I can see how not needing to include another import could be nice. However, I believe that if a customer is using typescript in their project, they are OK with adding more imports for types in their code. Also, they probably prefer a strongly typed API when interacting with our SDK. With this in mind, I do believe it's preferred that we replace any
with a strongly typed interface.
If we were to organize all of the interface
s in the project, I think the import statements for our SDK could look nice in a customer's app.
Here is an example of the imports could look like in a customer's app:
import type { PushPermissionOptions, Foo, Bar } from "customerio-reactnative/types"
import { CustomerIOTracking } from "customerio-reactnative"
...
I do not see this as a blocker for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small idea to share, I think changing the function name to something such as:
static async showPromptForPushNotifications(options?: any) : Promise<any>{ | |
static async askForPushPermission(options?: any) : Promise<any>{ |
would match the function naming of getPushPermissionStatus
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
This is a great suggestion. I will add this in a separate PR. I appreciate the suggestion.
-
I used "prompt" to make it specific that calling this method would show a prompt on the screen and not do something in the background.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I am OK with that while I am also OK with adding the changes to this PR.
- I am OK with either name. I hope using the word "prompt" doesn't confuse anyone where there are some cases where a prompt will not show up when this function is called. That's one reason why I suggested the name change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
I tried implementing
customerio-reactnative/types
and found that it has to be a completely new library inside ourcustomerio-reactnative
with it's own package.json, index.ts and other important files. Since we are waiting to release this feature on priority, I do not want to take more time learning & implementing it at the moment. But I really loved the suggestion and will make sure to add it in the future updates. I would also like to add other configs likeCioConfigOptions
to /types so that the importingcustomerio-reactive
could get reclustered as we release new features in future. -
I still lean towards having promt in the function name as it makes things clear to me as a user. I discussed with Rehan and we both had same POV.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- My code sample might have been bad as the solution I am thinking shouldn't be that complex. Here is a start to this work that I am testing now to see if we can sneak it into this release. I think our typescript customers will appreciate the strong types.
- Good idea to ask others. If other people are behind it, I am for it 👍
src/CustomerioTracking.tsx
Outdated
* @param options | ||
* @returns Success & Failure promises | ||
*/ | ||
static async showPromptForPushNotifications(options?: any) : Promise<any>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small idea to share, I think changing the function name to something such as:
static async showPromptForPushNotifications(options?: any) : Promise<any>{ | |
static async askForPushPermission(options?: any) : Promise<any>{ |
would match the function naming of getPushPermissionStatus
.
This reverts commit 43b55a6.
src/CustomerioTracking.tsx
Outdated
* Get status of push permission for the app | ||
* @returns Promise with status of push permission as a string | ||
*/ | ||
static getPushPermissionStatus() : Promise<any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static getPushPermissionStatus() : Promise<any> { | |
static getPushPermissionStatus() : Promise<PushPermissionStatus> { |
Going along with the comment about a strongly typed parameter for showPromptForPushNotifications
, we know the data type that is being returned from the Promise
.
We should be providing customers with a data type return value that they can easily parse in their code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏻
## [2.2.0](2.1.0...2.2.0) (2023-03-03) ### Features * push permission prompt ([#101](#101)) ([1abe9b3](1abe9b3))
closes: https://github.com/customerio/issues/issues/8746
closes: https://github.com/customerio/issues/issues/9493
This PR adds the ability to display a push notification permission prompt in the app. This gives the user the freedom to display a prompt at a later time in the app, which was previously only possible at app launch or by requiring the customer to utilise additional libraries.
Use case:
Show push permission prompt by calling
CustomerIO.showPromptForPushNotifications
from the javascript with configurable options such asbadge
andsound
.This PR also includes support for obtaining push permission authorisation status with a callback to perform action based on the response received. Call
CustomerIO.getPushPermissionStatus
to get the status.Use case: