firebase-php
firebase-php copied to clipboard
AndroidNotifcation extends Notification
Describe the feature you would like to see
It seems to me as if only AndroidConfig
would be supported, but not AndroidNotification
.
Alike this it's kind of difficult to set a channel_id
... or where does one have to pass this array?
You're right, the AndroidConfig
value object is not fully configurable yet, so at the moment, the only way to achieve this would be by passing the full android config as an arraz:
$message = CloudMessage::new()
// ...
->withAndroidConfig([
// ...
'notification' => [
'channel_id' => 'channel-id',
// ...
]
]);
I'll keep this as a feature request, but new features will probably only land in the upcoming major version (6.0) 🙏
@jeromegamez Thank you, works for me while it is being configurable. I've just noticed, because I currently write a similar library for Push Kit.
The click_action
& channel_id
probably should be documented (most commonly used).
Generally it would require these classes & enums:
class AndroidNotification
{
"title": string,
"body": string,
"icon": string,
"color": string,
"sound": string,
"tag": string,
"click_action": string,
"body_loc_key": string,
"body_loc_args": [
string
],
"title_loc_key": string,
"title_loc_args": [
string
],
"channel_id": string,
"ticker": string,
"sticky": boolean,
"event_time": string,
"local_only": boolean,
"notification_priority": enum (NotificationPriority),
"default_sound": boolean,
"default_vibrate_timings": boolean,
"default_light_settings": boolean,
"vibrate_timings": [
string
],
"visibility": enum (Visibility),
"notification_count": integer,
"light_settings": {
object (LightSettings)
},
"image": string
}
enum NotificationPriority
enum NotificationPriority {
'PRIORITY_UNSPECIFIED', // default value.
'PRIORITY_MIN',
'PRIORITY_LOW',
'PRIORITY_DEFAULT',
'PRIORITY_HIGH',
'PRIORITY_MAX'
}
enum Visibility
enum Visibility {
'VISIBILITY_UNSPECIFIED', // default value.
'PRIVATE',
'PUBLIC',
'SECRET'
}
class LightSettings
{
"color": {
object (Color)
},
"light_on_duration": string,
"light_off_duration": string
}
class Color
{
"red": number,
"green": number,
"blue": number,
"alpha": number
}
Where color.proto
for the LightSettings
would use (float) 0 - (float) 1
; generally a percentage.
It's indeed nice to have protos, if only they'd build for PHP ...
Can you please guide me how can I send a notification on particular date and time? I tried implementing in android but it is not working.
$message = CloudMessage::fromArray([
'topic' => 'all',
'notification' => ['title' => $postTitle, 'body' => $postTxt],
'android' => [
'priority' => 'high',
'notification' => [
'default_vibrate_timings' => true,
'default_sound' => true,
'notification_count' => 1,
'notification_priority' => 'PRIORITY_HIGH', // PRIORITY_LOW , PRIORITY_DEFAULT , PRIORITY_HIGH , PRIORITY_MAX
],
],
]);
//$messaging->send($message);
try {
//print_r($messaging->validate($message));
// or
// echo "hi";
$messaging->send($message);
} catch (InvalidMessage $e) {
print_r($e->errors());
}
Where can I add withAndroidConfig and event_time.
Looking at https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidnotification, you should be able to set the event_time
in the notification
payload.
Does event_time use for Scheduling Notifications? I think it is not.
May I know how can I schedule notification? Is there any provision?
You asked about event_time
, though 😅.
As far as I know it's not possible to schedule notifications, but I could be wrong (web-searching or StackOverflow could prove me right or wrong).
Ok. Thank you for your response :)