- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚将 MP4/GIF 附件添加到我的 iOS 应用程序的推送通知中。在播放方面一切正常。我面临的问题是发送 MP4 视频时,推送中发送的小缩略图看起来是透明的。然而,当我展开它时,它看起来很完美,我也可以在插入中很好地发挥它。当我发送转换为 GIF 的相同视频时,缩略图看起来也很完美。
这是一个例子:
上面的示例展示了两个不同的应用程序,只是为了展示 MP4 和 GIF 缩略图如何针对同一事件显示。如果我将 GIF 发送到顶部的应用程序,缩略图的输出看起来与 Pushover 应用程序缩略图完全一样。
下面是我滑动并查看缩略图(透明的)时发生的情况。这个特定的扩展缩略图用于不同的事件(我丢失了那个旧事件)。但我想说的是展开后的 View 看起来很完美。并且播放也很完美。
总而言之,在 IOS 中,当我将 MP4 文件作为附件发送时,小缩略图看起来是透明的,但回放效果很好。展开的缩略图看起来很完美。
这是我的客户端代码:
//
// NotificationService.m
// NotificationService
//
//
//
//
// Credit https://github.com/Leanplum/Leanplum-iOS-Samples/blob/master/iOS_basicSetup/basicSetup/richPushExtension/NotificationService.m
#import "NotificationService.h"
@interface NotificationService ()
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@end
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
NSDictionary *userInfo = request.content.userInfo;
// If there is no image in the payload than
// the code will still show the push notification.
if (userInfo == nil || userInfo[@"image_url_jpg"] == nil) {
NSLog(@"zmNinja Notification: Did not get a payload or image");
[self contentComplete];
return;
}
NSString *mediaUrl = userInfo[@"image_url_jpg"];
// if (mediaType == nil) {
// NSLog(@"zmNinja Notification: No media type specified, assuming .jpg");
// mediaType = @".jpg";
// }
// load the attachment
[self loadAttachmentForUrlString:mediaUrl
completionHandler:^(UNNotificationAttachment *attachment) {
if (attachment) {
self.bestAttemptContent.attachments = [NSArray arrayWithObject:attachment];
}
[self contentComplete];
}];
}
- (NSString*)determineType:(NSString *) fileType {
// Determines the file type of the attachment to append to NSURL.
//return @".gif";
// Determines the file type of the attachment to append to NSURL.
NSLog (@"zmNinja Notification: determineType got filetype=%@",fileType);
if ([fileType isEqualToString:@"image/jpeg"]){
NSLog (@"zmNinja Notification: returning JPG");
return @".jpg";
}
if ([fileType isEqualToString:@"video/mp4"]){
NSLog (@"zmNinja Notification: returning MP4");
return @".mp4";
}
if ([fileType isEqualToString:@"image/gif"]) {
NSLog (@"zmNinja Notification: returning GIF");
return @".gif";
}
if ([fileType isEqualToString:@"image/png"]) {
NSLog (@"zmNinja Notification: returning PNG");
return @".png";
}
NSLog (@"zmNinja Notification: unrecognized filetype, returning JPG");
return @".jpg";
}
- (void)loadAttachmentForUrlString:(NSString *)urlString
completionHandler:(void(^)(UNNotificationAttachment *))completionHandler {
__block UNNotificationAttachment *attachment = nil;
NSURL *attachmentURL = [NSURL URLWithString:urlString];
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
[[session downloadTaskWithURL:attachmentURL
completionHandler:^(NSURL *temporaryFileLocation, NSURLResponse *response, NSError *error) {
if (error != nil) {
NSLog(@"unable to add attachment: %@", error.localizedDescription);
} else {
NSString *fileType = [self determineType: [response MIMEType]];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *localURL = [NSURL fileURLWithPath:[temporaryFileLocation.path stringByAppendingString:fileType]];
[fileManager moveItemAtURL:temporaryFileLocation toURL:localURL error:&error];
NSError *attachmentError = nil;
attachment = [UNNotificationAttachment attachmentWithIdentifier:@"" URL:localURL options:nil error:&attachmentError];
if (attachmentError) {
NSLog(@"unable to add attchment: %@", attachmentError.localizedDescription);
}
}
completionHandler(attachment);
}] resume];
}
- (void)contentComplete {
self.contentHandler(self.bestAttemptContent);
}
- (void)serviceExtensionTimeWillExpire {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
NSLog (@"zmNinja Notification: Time about to expire, handing off to best attempt");
self.contentHandler(self.bestAttemptContent);
}
@end
服务器端使用 FCM 遗留 API:
my $ios_message = {
to => $obj->{token},
notification => {
title => $title,
body => $body,
sound => "default",
badge => $badge,
},
data => {
myMessageId => $notId,
mid => $mid,
eid => $eid,
summaryText => $eid
}
};
$ios_message->{data}->{image_url_jpg} = $pic; # $pic is a URL for the mp4
# image_url_jpg is just a field name. It was originally meant for static images
# haven't changed it yet, as you see in client code above, it uses that field.
$json = encode_json($ios_message);
my $req = HTTP::Request->new( 'POST', $uri );
$req->header(
'Content-Type' => 'application/json',
'Authorization' => $key
);
$req->content($json);
my $lwp = LWP::UserAgent->new(%ssl_push_opts);
my $res = $lwp->request($req);
最后,如果您想查看示例 MP4 以排除任何格式问题,这是我上传到谷歌驱动器 (link) 的一个。我已经使用 ffshow 提取了帧信息,它对我来说并没有错位(而且它播放得很好)。
谁能帮我理解为什么最初的小缩略图在 iOS 中看起来乱七八糟? (如果有帮助,我在 iOS 13.x 上)谢谢。
最佳答案
遇到了同样的问题。通过创建 notification content extension 来解决它并发送缩略图 URL 和视频 URL。
在服务扩展中,我将视频和缩略图都添加为附件,缩略图作为第一个元素,iOS 将在通知预览中显示:
// mediaAttachment and thumbnailAttachment are UNNotificationAttachments
// that have just been downloaded
if let mediaAttachment = mediaAttachment {
mutableContent.attachments = [mediaAttachment]
}
if let thumbnailAttachment = thumbnailAttachment {
mutableContent.attachments.insert(thumbnailAttachment, at: 0)
}
contentHandler(mutableContent)
扩展的通知 UI 由替换默认 UI 的内容扩展处理,我忽略了缩略图,只显示视频,这将是最后一个附件。
关于iOS 富通知 : Sending MP4 files result in transparent thumbnails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60812895/
我想要一个具有透明背景的图表,因此 PNG 似乎是一个不错的选择。但是当我设置透明背景时,轴标签的质量急剧下降。我该如何解决?请参阅以下代码。就目前而言,图表具有透明背景,正如我所希望的,但文本质量很
我正在尝试制作一个透明的谷歌图表,但它似乎不起作用。它只是绘制纯白色背景。 有没有人在透明度方面取得成功? 难道我做错了什么? 提前致谢! 谷歌图表信息:solid fill 测试网址: Google
我有一个 subview 已添加到我的 UIView 中。这个想法是 subview 是一个带有 uibuttons 的悬停面板。 subview 的 alpha 值为 0.2,因为用户需要能够看到其
如何在不影响表单控件的情况下更改表单的 alphablend? 德尔福XE7 最佳答案 此问题的一个解决方案是使用多设备应用程序(如果无法使用VCL)。 如果您需要保留透明的TForm,只需更改属性T
嗨,我正在用 mvc4 做我的元素。在我的布局页面中,我有一个透明的 div(#wrapper),最重要的是我有许多非透明的 div。为此,我使用了以下 css 和 html 代码。
我有黑色和透明的简单图像,想将其更改为白色和透明。我想保持透明度(80% 黑色和 20% 透明 >> 80% 白色和 20% 透明,30% 黑色和......)。我尝试了填充桶,但没有成功。 据我所知
我有一组位图。它们在某种程度上都是透明的,我事先不知道哪些部分是透明的。我想从排除透明部分但在正方形中的原始位图中创建一个新位图。我认为这张图片解释了这一点: 我知道如何从现有位图中创建位图,但我不知
我整个下午都在尝试第一次使用 expo-cli 运行 expo build:ios,这样我就可以将我的第一个 expo 应用程序放到 TestFlight 上,但我反复收到错误消息:“你的应用程序图标
我想知道为什么在 Mac OS X 上的滚动条有时是白色透明的,有时是黑色透明的,如果您在常规设置中将“显示滚动条”设置为“滚动时”。所有浏览器(Safari、Chrome、Firefox、Opera
这个问题在这里已经有了答案: Difference between "-webkit-text-fill-color" and "color"? (2 个答案) 关闭 4 年前。
我想为我的应用程序开发一个配置文件屏幕。我正在使用 AppCompactActivity,因为我需要我的应用程序也支持非 Lollipop 设备。我只需要为应用程序中的这个特定 Activity 屏幕
第一个场景: h1{ text-align: center; } td{ width: 100px; height: 100px; border-right: 1px solid gray; bord
我在 Google Earth Engine 中工作,正在尝试创建一种无颜色/完全透明的颜色(无边框和无填充)。下面是一行代码,其中第一种颜色应该是透明的“颜色”。基本上我希望我的最小值根本不显示在
我在HTML5 Canvas 上玩createRadialGradient()。除非我要实现(半)透明性,否则它的工作原理就像一种魅力。 我做了这个jsFiddle以使事情更清晰:http://jsf
我需要从 www.webwoods.co.uk/lsss/index.html(黑色和红色的星星)的网站图标中删除白色背景 有没有办法用常用的图形编辑器(Adobe CC、Paint 等)来做到这一点
我需要使用透明度(背景每隔几秒钟更改一次)找到图像(检测游戏中的文本)。我的脚本: #include HotKeySet("s", "Start") $x = 0 $y = 0 Func Start
环境:WebGL,Chrome。将透明png用作模型的纹理时,我有以下行为: 图片A-树将建筑物隐藏在其后,我看到了世界框纹理。它还隐藏自身(后分支不可见) 同时-图片B-正常运行,窗口是透明的,我看
我正在尝试将水印渲染到视频中。一旦水印的图像文件 (.png) 包含透明度,图像就不再渲染到视频中。如果我将该图像转换为 .jpg 然后再转换回 .png,效果很好。如果我创建一个没有透明度的新 pn
我正在使用tilemill来生成mbtile。有人知道如何使mbtiles背景透明吗? 最佳答案 您的默认样式将具有类似的规则 Map { background-color:#f00; } 这为
我有一个奇怪的问题,我在尝试在 WebGL 中进行混合时无法弄清楚。黑色呈现为完全透明,所有带有灰色阴影的内容也呈现为半透明。我已经将它设置为使用 alpha channel 作为透明度的来源,并且在
我是一名优秀的程序员,十分优秀!