0
在丰富的推送消息中,我知道它使用的html格式。问题是我没有提供任何特定的服务器服务available.Is有一些方法来显示图像的消息,而无需托管它换句话说,除了图像标签之外,html中是否有任何方法可以在html中显示图像?内容本地存储在html页面本身?或者还有其他可能的方式吗?将图像添加到Urban Airship丰富的推文排版
语言:Ç的OBJ
在丰富的推送消息中,我知道它使用的html格式。问题是我没有提供任何特定的服务器服务available.Is有一些方法来显示图像的消息,而无需托管它换句话说,除了图像标签之外,html中是否有任何方法可以在html中显示图像?内容本地存储在html页面本身?或者还有其他可能的方式吗?将图像添加到Urban Airship丰富的推文排版
语言:Ç的OBJ
我行与HTML(富文本消息)发送图像 - 这使得收件箱中进行离线阅读。
你没有指定你使用什么编程语言,所以我给你什么,我在PHP已经有了:
/**
* htmlReportImageFromUrl - Takes a url to an image (png), return a html inline image in a <div/>
*
* @author Kent Behrends, [email protected], 2012-04-12
* @param string $url to a png image
* @param string $imageFormat and format that Imagick supports, default to 'png'
* @param int $resizeImage in pixels, defualt to 48
* @param string $altText for the image
* @return string html <div/> string with image data or <div>Bad Image</div>
*/
function htmlReportImageFromUrl($url, $imageFormat = "png", $resizeImage = "48", $altText = "image") {
$image = new Imagick();
$f = fopen ($url, 'rb');
$status = $image->readImageFile ($f);
fclose ($f);
if (! $status) return '<div>Bad Image</div>';
$image->setImageFormat ($imageFormat);
$image->resizeImage ($resizeImage, 0, imagick::FILTER_LANCZOS, - 1);
$encoded = base64_encode ($image->getImageBlob());
return '<div><img src="data:image/png;base64,' . $encoded . '" alt="'.$altText.'"></div>';
}
使用此功能的一个例子,它的输出。
$kentsImage = 'http://www.gravatar.com/avatar/6376f5c874dd475857c1b4c082f2e665?s=128&d=identicon&r=PG';
$message = '<html><body>';
$message .= '<h4>Sample image from gravatar.com</h4>';
$message .= '<table><tr><td>Kent</td><td>'.htmlReportImageFromUrl($kentsImage).'</td></tr></table>';
$message .= '</body></html>';
print $message;
你会送$消息作为有效载荷飞艇城市航空邮件网址:
格式化输出,将src =“数据:图像/ PNG ...已被截断:
<html>
<body>
<h4>Sample image from gravatar.com</h4>
<table>
<tr>
<td>Kent</td>
<td>
<div><img src="data:image/png;base64,iVBORw0KGgoAAAANS ...</div>
</td>
</tr>
</table>
</body>
</html>
哦fgt提到tht.This是为obj c –
@ ithu-thiruvathira你从iOS设备或OS X的丰富推动? – Kent
ios设备..更具体的ipad .. –