edamov / pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key)
MIT License
378 stars 120 forks source link

Set custom alert values #130

Closed KoIIIeY closed 3 years ago

KoIIIeY commented 3 years ago

https://github.com/laravel-notification-channels/apn/issues/121

https://pub.dev/packages/flutter_ios_voip_kit - flutter wants data like this: { "aps": { "alert": { "uuid": <Version 4 UUID (e.g.: https://www.uuidgenerator.net/version4) >, "incoming_caller_id": , "incoming_caller_name": , } } }

Can anyone help?

KoIIIeY commented 3 years ago

As a variant, in setCustomValue (Payload.php, line 342) can be array_merge, except existing $this->customValues[$key] = $value; so we can set custom value for every key in payload.

KoIIIeY commented 3 years ago

Payload.php line 342

public function setCustomValue(string $key, $value): Payload { $this->customValues = array_merge_recursive($this->customValues ? $this->customValues : [], [$key => $value]);

return $this;

}

@edamov , can you change your code like this?

With that variant I can send VOIP pushes to flutter as public function toApnVoip($notifiable) { return ApnVoipMessage::create() ->custom('aps', ['alert' => ['incoming_caller_id' => '345345345', 'incoming_caller_name' => 'from PHP!', 'uuid' => '982cf533-7b1b-4cf6-a6e0-004aab68c503']]) ->badge(1); }

KoIIIeY commented 3 years ago

https://github.com/edamov/pushok/pull/131/commits/b53f7811761d8281c7fa438b42784cc74a6acfc6

KoIIIeY commented 3 years ago

@edamov , can you check this?