Closed LLouzada closed 1 year ago
Hello @LLouzada1,
Thank you for asking!
You can add any Android specific keys for notification messages, as well as android_channel_id
. Just pass array of configs to setAndroidConfig()
method with android_channel_id
key-value under notification
section (see example below).
/** @var \aksafan\fcm\source\responses\apiV1\TokenResponse $result */
$result = Yii::$app
->fcm
->createRequest()
->setTarget(\aksafan\fcm\source\builders\apiV1\MessageOptionsBuilder::TOKEN, 'your_token')
->setAndroidConfig([
'ttl' => '3600s',
'priority' => 'normal',
'notification' => [
'title' => 'Android Title',
'body' => 'Android Description.',
'icon' => 'stock_ticker_update',
'color' => '#ff0000',
'android_channel_id' => '123456',
],
])
->send();
Make sure to create a channel with this channel ID before any notification with this channel ID is received. Ref to official documentation (Table 2b. Android — keys for notification messages):
Hi @bc-anton-k , thank you for your reply!
Me and my team managed to make it work using the key channel_id, not android_channel_id, as mentined in here https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#AndroidNotification.
But I guess the way you showed should work too, anyway, thank you for your time :)
Is it possible to set the channel id for android? I tried adding "android_channel_id" to setAndroidConfig, 'notification' => [ 'title' => $title, 'body' => $message, 'android_channel_id' => $type, ], But this seems not to work.