Skip to content
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

Refactor FcmMessage to make simpler #172

Merged
merged 7 commits into from
Oct 15, 2023
Merged

Refactor FcmMessage to make simpler #172

merged 7 commits into from
Oct 15, 2023

Conversation

dwightwatson
Copy link
Collaborator

@dwightwatson dwightwatson commented Oct 13, 2023

This makes a few major changes to greatly simplify the interface of FcmMessage so that it generally covers 90% off the use-case with ease, but still allows it to be used for more advanced use-cases as required.

  • The attributes of the FcmMessage are given types and made public so that getters are not required,
  • The validation of custom data is removed and left to the end-user,
  • Most of the "resource" objects we provided are removed, as they are likely incomplete (not fulfilling the complete API),
  • Adds test coverage over the new interface.

If you need to build a highly specific custom message to send you can simply return what you like from toFcm instead of using our FcmMessage instance. Alternatively, you can now use custom an instance to instead provide your own additional custom configuration with arrays.

use NotificationChannels\Fcm\FcmMessage;
use NotificationChannels\Fcm\Resources\Notification;

$message = FcmMessage::create()
    ->name('name')
    ->notification(Notification::create()->title('title'))
    ->custom([
        'android' => [
            // ...
        ],
    ]);

Todo

  • Update the README

@dwightwatson
Copy link
Collaborator Author

Upon reflection I think it may still be worth keeping the Notification instance around.

@dwightwatson dwightwatson merged commit 86eb51a into master Oct 15, 2023
4 of 5 checks passed
@dwightwatson dwightwatson deleted the refactor_message branch October 15, 2023 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant