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

AndroidNotifcation extends Notification #677

Open
syslogic opened this issue Jan 4, 2022 · 7 comments
Open

AndroidNotifcation extends Notification #677

syslogic opened this issue Jan 4, 2022 · 7 comments

Comments

@syslogic
Copy link

syslogic commented Jan 4, 2022

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?

@jeromegamez
Copy link
Member

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) 🙏

@syslogic
Copy link
Author

syslogic commented Jan 4, 2022

@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 ...

@dhwalin
Copy link

dhwalin commented Jun 8, 2023

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.

@jeromegamez
Copy link
Member

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.

@dhwalin
Copy link

dhwalin commented Jun 9, 2023

Does event_time use for Scheduling Notifications? I think it is not.

May I know how can I schedule notification? Is there any provision?

@jeromegamez
Copy link
Member

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).

@dhwalin
Copy link

dhwalin commented Jun 9, 2023

Ok. Thank you for your response :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants