<bdo id='NGYYT'></bdo><ul id='NGYYT'></ul>

    1. <legend id='NGYYT'><style id='NGYYT'><dir id='NGYYT'><q id='NGYYT'></q></dir></style></legend>

      <small id='NGYYT'></small><noframes id='NGYYT'>

      <i id='NGYYT'><tr id='NGYYT'><dt id='NGYYT'><q id='NGYYT'><span id='NGYYT'><b id='NGYYT'><form id='NGYYT'><ins id='NGYYT'></ins><ul id='NGYYT'></ul><sub id='NGYYT'></sub></form><legend id='NGYYT'></legend><bdo id='NGYYT'><pre id='NGYYT'><center id='NGYYT'></center></pre></bdo></b><th id='NGYYT'></th></span></q></dt></tr></i><div id='NGYYT'><tfoot id='NGYYT'></tfoot><dl id='NGYYT'><fieldset id='NGYYT'></fieldset></dl></div>
      <tfoot id='NGYYT'></tfoot>
    2. 在带有 FCM 的 iOS 上使用富推送通知中的数据

      时间:2023-07-29
    3. <tfoot id='o3IVK'></tfoot>
      <legend id='o3IVK'><style id='o3IVK'><dir id='o3IVK'><q id='o3IVK'></q></dir></style></legend>

            <tbody id='o3IVK'></tbody>

            <i id='o3IVK'><tr id='o3IVK'><dt id='o3IVK'><q id='o3IVK'><span id='o3IVK'><b id='o3IVK'><form id='o3IVK'><ins id='o3IVK'></ins><ul id='o3IVK'></ul><sub id='o3IVK'></sub></form><legend id='o3IVK'></legend><bdo id='o3IVK'><pre id='o3IVK'><center id='o3IVK'></center></pre></bdo></b><th id='o3IVK'></th></span></q></dt></tr></i><div id='o3IVK'><tfoot id='o3IVK'></tfoot><dl id='o3IVK'><fieldset id='o3IVK'></fieldset></dl></div>

              <small id='o3IVK'></small><noframes id='o3IVK'>

              • <bdo id='o3IVK'></bdo><ul id='o3IVK'></ul>
                本文介绍了在带有 FCM 的 iOS 上使用富推送通知中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我的问题可能很糟糕,但我在任何地方都找不到任何答案,我迷路了......

                My question might be bad, but I can't find any answer anywhere, I'm lost...


                所以我想在 iOS 10+ 中显示一个带有漂亮图像的丰富通知.


                So I want to display a rich notification with a nice image in iOS 10+.

                为此,我使用 FCM 和 UNNotificationServiceExtension,如果我理解正确,它应该获取数据负载,找到图像 URL 并在修改 UNNotificationContent 之前加载它.

                For this I'm using FCM and an UNNotificationServiceExtension which, if I understood correctly, should get the Data payload, find the image URL and load it before modifying the UNNotificationContent.

                我的问题是我无法掌握这些数据".

                The issue I have is that I can't get a hold of this "data".

                我发送给 FCM 的内容如下:

                What I'm sending to FCM is the following :

                {
                "to": "device_token",
                "content_available": true,
                "mutable_content": true,
                "badge" : 9,
                "notification": {
                    "title": "You still need the iPhone ?",
                    "body": "Give it back if you finished you tests !"
                },
                "data": {
                    "message": "test !",
                    "mediaUrl": "http://usr.audioasylum.com/images/2/20352/Cat_and_rose.jpg"
                },
                "priority": "high"
                }
                

                我在电话里得到的是:

                {
                aps =     {
                    alert =         {
                        body = "Give it back if you finished you tests !";
                        title = "You still need the iPhone ?";
                    };
                    "content-available" = 1;
                    "mutable-content" = 1;
                };
                "gcm.message_id" = "0:1489054783357873%1ee659bb1ee659bb";
                mediaUrl = "http://usr.audioasylum.com/images/2/20352/Cat_and_rose.jpg";
                message = "Offer!";
                }
                

                据我了解,mediaURL 和消息应该以aps"结尾而不是外部,这就是为什么我在扩展程序中找不到它们的原因.

                As I understand it, the mediaURL and message should end up in "aps" and not outside, which is why I can't find them in the extension.

                在我得到的扩展中:(为了提高可读性,我将其拆分为昏迷)

                And inside the extension I get : (I split it on coma for more readability)

                <UNNotificationRequest: 0x117d3c170;
                identifier: FDC13B60-FE5A-40C6-896D-06D422043CCE
                content: <UNNotificationContent: 0x117d3a650; title: You still need the iPhone ?
                subtitle: (null)
                body: Give it back if you finished you tests !
                categoryIdentifier: 
                launchImageName: 
                peopleIdentifiers: ()
                threadIdentifier: 
                attachments: ()
                badge: (null)
                sound: (null)
                hasDefaultAction: YES
                shouldAddToNotificationsList: YES
                shouldAlwaysAlertWhileAppIsForeground: NO
                shouldLockDevice: NO
                shouldPauseMedia: NO
                isSnoozeable: NO
                fromSnooze: NO
                darwinNotificationName: (null)
                darwinSnoozedNotificationName: (null)
                trigger: <UNPushNotificationTrigger: 0x117d3fe90; contentAvailable: YES
                 mutableContent: YES>>
                

                问题是我如何使用 FCM 发送信息,还是我检索它们的方式?也许这就是我对待他们的方式?

                Is the problem how I send information with FCM, or the way I retrieve them? Maybe it's the way I treat them ?

                一如既往,感谢您的帮助!

                As always, thanks for the help!

                为接收器添加代码(只是扩展中的打印)

                Edit : Added code for the receiver (which is just a print in the extension)

                @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];
                
                    NSLog(@"------------------- %@ -------------------", request);
                
                    // Modify the notification content here...
                    self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [modified]", self.bestAttemptContent.title];
                    self.bestAttemptContent.body = [NSString stringWithFormat:@"%@", request.content];
                    self.contentHandler(self.bestAttemptContent);
                }
                

                推荐答案

                我认为你应该检查 self.bestAttemptContent?.userInfo 以获取 mediaUrl 数据.

                I think you should check self.bestAttemptContent?.userInfo for mediaUrl data.

                这篇关于在带有 FCM 的 iOS 上使用富推送通知中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:调用 FirebaseInstanceId.getToken 的行为 下一篇:图片未显示在推送通知中

                相关文章

                  <bdo id='NqIdQ'></bdo><ul id='NqIdQ'></ul>
                <i id='NqIdQ'><tr id='NqIdQ'><dt id='NqIdQ'><q id='NqIdQ'><span id='NqIdQ'><b id='NqIdQ'><form id='NqIdQ'><ins id='NqIdQ'></ins><ul id='NqIdQ'></ul><sub id='NqIdQ'></sub></form><legend id='NqIdQ'></legend><bdo id='NqIdQ'><pre id='NqIdQ'><center id='NqIdQ'></center></pre></bdo></b><th id='NqIdQ'></th></span></q></dt></tr></i><div id='NqIdQ'><tfoot id='NqIdQ'></tfoot><dl id='NqIdQ'><fieldset id='NqIdQ'></fieldset></dl></div>

                1. <tfoot id='NqIdQ'></tfoot>
                    <legend id='NqIdQ'><style id='NqIdQ'><dir id='NqIdQ'><q id='NqIdQ'></q></dir></style></legend>

                  1. <small id='NqIdQ'></small><noframes id='NqIdQ'>