Hello guys. I'm trying to display image on a iOS notification.
Here is the url : https://firebasestorage.googleapis.com/v0/b/xxxxxxx.appspot.com/o/DEV-2-Ronnie%2F2020-04-05-IMG_0006.HEIC?alt=media&token=xxxxxx.jpg (still works April 8, 2020)
(I can't remove ?token...)
My push notification is created by API. It works for 99% of my images but except when it comes from Firebase.
So to resume : My backend code can create push notification with or without images. But if images comes from Firebase it doesn't work.
How can I solve that please ?
Howdy,
Can you please include a code snippet where you are setting this on the backend?
Also, are you sending to Android as well?
Closing due to no response
Oops, I'm very sorry @rgomezp.
I didn't see you have replied. How to reopened it?
I'm sending only to iOS devices.
Here is the snippet in my backend
function buildPayload($externalUserIds, $content, $title, $subtitle, $ios_attachments, $url, $customData) {
$data_externalUserIds = isset( $externalUserIds ) ? $externalUserIds : array("34");
$data_content = isset( $content ) ? $content : "Tu as une nouvelle notification";
$data_title = isset( $title ) ? $title : null;
$data_subtitle = isset( $subtitle ) ? $subtitle : null;
$data_url = isset( $url ) ? $url : null;
$data_imageUrl = isset( $ios_attachments ) ? $ios_attachments : null;
$data_customData = isset( $customData ) ? $customData : null;
$oneSignal_appID = "";
$fields = array(
'app_id' => $oneSignal_appID,
'headings' => $data_title,
'subtitle' => $data_subtitle,
'contents' => $data_content,
'include_external_user_ids' => $data_externalUserIds,
'data' => $data_customData,
'url' => $data_url,
'ios_attachments' => $data_imageUrl,
'ios_badgeType' => 'Increase', // 'SetTo',
'ios_badgeCount' => 1
);
$fields = json_encode($fields);
return $fields;
}
function sendToOneSignal ($fields) {
$oneSignal_restAPI = "";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Authorization: Basic ' . $oneSignal_restAPI
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
This code above works, in production. Users can receive notifications.
But they cannot see images if image comes from firebase...
@Steffi3rd Can you generate a URL that has .jpg instead of .HEIC so the final URL looks like this?
https://firebasestorage.googleapis.com/v0/b/xxxxx.appspot.com/o/DEV-2-Ronnie%2F2020-04-05-IMG_0006.jpg?alt=media&token=xxxxxxxxxxxx.jpg
This has to due with iOS not automatically detecting the file type and the OneSignal-iOS-SDK taking an attempt at it based on the URL.
https://github.com/OneSignal/OneSignal-iOS-SDK/issues/134#issuecomment-285159398
I think there is so improvement the OneSignal-iOS-SDK can make in detection so your original URL works however hopely the work around for you works for now.
Hello
Thanks for you answer.
I鈥檓鈥檜sing the React Native SDK, and the REST API.
So the solution is to rename as an .jpg instead of .HEIC, even the file is still a HEIC file ?
(@jkasten2 Can you please edit your comment and mais/hide the domain of my url please 馃檹 i made a mistake by sharing it as public)
@Steffi3rd Yes correct, that should work around the issue for now.
Edit my last comment per your request.
Closing due to no response
Hello here 馃憢
I wanna say that it works now (since yesterday) without any code change!
Images from firebase (without extension) are now display in iOS Notifications.
Did you made a release to fix that? I'm interested to see how it was fixed.
Thanks!
Howdy @Steffi3rd ,
I'm not seeing anything done from our end that may have resolved the issue.
Most likely it was due to an issue covered in this troubleshooting guide.
Enjoy!
Most helpful comment
Hello here 馃憢
I wanna say that it works now (since yesterday) without any code change!
Images from firebase (without extension) are now display in iOS Notifications.
Did you made a release to fix that? I'm interested to see how it was fixed.
Thanks!