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

time_to_live - how do you set it? #22

Open
lew-kni opened this issue Jul 24, 2017 · 1 comment
Open

time_to_live - how do you set it? #22

lew-kni opened this issue Jul 24, 2017 · 1 comment

Comments

@lew-kni
Copy link

lew-kni commented Jul 24, 2017

Hi,

Thanks for the amazing plugin, it's really helped in us implementing FCM through PHP.

I'm trying to look at a way to set 'time_to_live' through the options but can't seem to get it working through
$message->setJsonKey('time_to_live', 0);

Also i have some messages having content_available with setJsonKey, can we do
$message->setJsonKey(array("content_available" => true, "time_to_live" => 0));
??

I couldn't seem to see any reference for setJsonKey in any documentation for this repo but i know it's within FCM docs.

Thanks,

Lew.

@jahrralf
Copy link

jahrralf commented Nov 23, 2017

Try this:

// Set timeouts
$log->debug("Serialized message before adding timeouts: " . json_encode($message));
$message->setJsonKey("apns", ["headers" => ["apns-expiration" => time() + self::MESSAGE_TIMEOUT_SEC]]);
$message->setJsonKey("android", ["ttl" => self::MESSAGE_TIMEOUT_SEC . "s"]);
$message->setJsonKey("webpush", ["headers" => ["TTL" => self::MESSAGE_TIMEOUT_SEC . ""]]);
$log->debug("Serialized message after adding timeouts: " . json_encode($message));

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

No branches or pull requests

2 participants