如何向用户提供Rich NotificationService(包括图像图标)?

时间:2017-10-03 06:18:12

标签: ios swift3 push-notification apple-push-notifications rich-notifications

最近我正在开发一个项目,它需要嵌入丰富的通知。所以我从firebase服务。最初我试过这些网站。 youtube中有一些业余爱好项目,他们从本地机器发送通知。

https://www.avanderlee.com/ios-10/rich-notifications-ios-10/

UNNotificationAttachment with UIImage or Remote URL

How to implement rich notifications in ios 10 with Firebase

How to send Image with firebase Push Notification using swift 3

但我花了差不多16个小时。它给了我0输出,因为标题,副标题来自firebase精细但没有图像图标的迹象。

请向我推荐任何方法或好视频或其他内容。

1 个答案:

答案 0 :(得分:0)

您的应用目标的plist应包含以下行

<key>NSExtensionPointIdentifier</key> 
<string>com.apple.usernotifications.service</string> 
<key>NSExtensionPrincipalClass</key> 
<string>$(PRODUCT_MODULE_NAME).NotificationService</string>

您的扩展程序的plist应如下所示

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>RemotePushExtension</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>XPC!</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1.12</string>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>NSExtension</key>
    <dict>
        <key>NSExtensionPointIdentifier</key>
        <string>com.apple.usernotifications.service</string>
        <key>NSExtensionPrincipalClass</key>
        <string>NotificationService</string>
    </dict>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Want to access your photo album to save image</string>
</dict>
</plist>