I am working on a iOs and Android Application built on top of react-native and using aws pinpoint for the push notifications. i have managed to get the notifications using aws-amplify library for react native and when i test notifications using aws-pinpoint test tool it works without a problem. however i am having problem with sending notifications using php.
I've tried using this documentation (https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-pinpoint-2016-12-01.html#sendmessages) and in Ios it gives following Error :
{
"errorMessage": "Invalid notification",
"channelType": "APNS",
"pushProviderStatusCode": "0",
"pushProviderError": "Notification is malformed"
}
Here is the PHP code i'm trying
$settings=array(
'version' => '2016-12-01', // have tries 'latest' too
'region' => 'us-east-1',
'credentials' => [
'key' => 'XXXXXXXXX',
'secret' => 'XXXXXX',
]
);
$pin = new Aws\Pinpoint\PinpointClient($settings);
$msgios=array(
'ApplicationId' => 'XXXXXXXX',
'MessageRequest' => [
'Addresses' => [
'06fdf172694c5d6461b3d8a20308720674XXXXXXXXX' => [
'BodyOverride' => 'aaa',
'ChannelType' => 'APNS',
'RawContent' => 'bbb',
'Context' => ['ccc' => '222'],
'TitleOverride' => 'ddd',
],
],
'Context' => ['hello'=>'yes', 'value'=>'key'],
'MessageConfiguration' => [
'APNSMessage' => [
'Action' => 'OPEN_APP',
'Badge' => 2,
'Body' => 'Hello There',
'Category' => 'iOS',
'CollapseId' => 'Yes',
'Data' => ['age'=>13,'Name'=>"Saman"],
'MediaUrl' => null,
'PreferredAuthenticationMethod' => '',
'Priority' => '10',
'RawContent' => 'Hello',
'SilentPush' => true,
'Sound' => 'default',
'Substitutions' => [
'ages' => ['10', '13'],
],
'ThreadId' => '10',
'TimeToLive' => 10,
'Title' => 'There',
'Url' => null,
],
'DefaultMessage' => [
'Body' => 'Hello there',
'Substitutions' => [
'ages' => ['10', '13'],
],
],
'DefaultPushNotificationMessage' => [
'Action' => 'OPEN_APP',
'Body' => 'Hello',
'Data' => ['age'=>13,'Name'=>"Saman"],
'SilentPush' => true,
'Substitutions' => [
'ages' => ['10', '13'],
],
'Title' => 'Hello',
'Url' => null,
],
],
'TraceId' => '1024585',
],
);
$result = $pin->sendMessages($msgios);
I get above error from iOs and when i Use 'GCM' and and push it to android notification is coming to the device (i can see it in the console) but not in the right format.
iOS and Andoird notifications works perfectly from AWS pinpoint dashboard :
(source: kayantemp.com)
I think i'm not using the right syntax or the API version. appreciate your help.