I’m trying send a voip push notification but it’s return InvalidPushType, how you can see in the image.
And my code to make the request with Curl PHP
if (defined("CURL_VERSION_HTTP2") && (curl_version()["features"] & CURL_VERSION_HTTP2) !== 0) {
$device_token = "1302E8106AA322DE917B2D0F0FC4D656878F878E8E2FCEA9CEA153D3C80027C7";
$body["aps"] = array(
"alert" => "callIOS",
"id" => "eabeae54-14a8-11e5-b60b-1697f925ec7b",
"nameCaller" => "Hien Nguyen",
"handle" => "0123456789",
"isVideo" => true
);
$header[] = "apns-topic: ao.medicare.app";
$header[] = "apns-expiration: 0";
$header[] = "apns-priority: 10";
$header[] = "apns-push-type: voip";
$header[] = "Content-Type: application/x-www-form-urlencoded";
$header[] = "apns-id: eabeae54-14a8-11e5-b60b-1697f925ec7b";
$ch = curl_init();
$url = "https://api.sandbox.push.apple.com/3/device/" . $device_token;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_HTTPHEADER, $header);
curl_setopt($ch,CURLOPT_POSTFIELDS, json_encode($body));
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_SSLCERT, "VOIP.pem");
curl_setopt($ch,CURLOPT_SSLCERTPASSWD, "");
$response = curl_exec($ch);
$err = curl_error($ch);
print_r(json_decode($response));
print_r(json_decode($err));
curl_close($ch);
} else {
echo "No HTTP/2 support on client.";
}
I’m following the official doc here
Edit: I try add .voip at the end of apns-topic (ao.medicare.app.voip), don’t work.
2
Answers
Solved
I was getting the wrong APNs token, the right way to get APNs token in flutter is colling this function:
From the documentation you linked to:
Therefore you must specify
apns-topic
asao.medicare.app.voip