未调用iOS10 UNNotificationServiceExtension [英] iOS10 UNNotificationServiceExtension not called

查看:1236
本文介绍了未调用iOS10 UNNotificationServiceExtension的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实施新的iOS10扩展程序以使用丰富的通知。我试图在推送通知上测试但是没有用,我只是收到一个简单的通知而没有通过扩展。

Im implementing new iOS10 extension to use rich notifications. Im trying to test it on push notifications but is not working, I just receive a simple notification and is not going through the extension.

我做了所有它在官方网站和其他一些地方:

I did all that it's specified in the official sites and some other places:


  • 我的应用程序启动并运行推送通知和正确的配置文件

  • 我在我的应用程序中添加了一个新目标,一个通知服务扩展

  • 实现了我自己的代码(真的没关系,因为甚至没有进入新类)

  • 此外,我还必须为此扩展设置配置文件,我只使用带有通配符的配置文件,我没有看到任何文档指定扩展目标是否必须启用推送通知功能,在这种情况下,我需要一个特定的配置,目前我只是使用通配符,无论如何它匹配(它必须匹配)我在应用程序目标中使用的配置文件,并启用推送通知功能的应用程序tar只获得。

  • 我添加了UNNotificationExtensionCategory和NSExtensionPointIdentifier。我也是从服务器发送类别作为推送有效载荷的一部分。

  • I have my app up and running with push notifications and the right provisioning profile
  • I added a new target to my app, a Notification Service Extension
  • Implemented my own code (it doesn't matter really because is not even entering to the new class)
  • Also I had to set a provisioning profile for this extension, I just use one with a wildcard, I don't see any documentation specifying if the extension target has to enable push notifications capability, in that case I would need a specific provisioning for this one, at the moment I just use a wildcard prov, anyway it matches (it must match) the profile I use in the app target, and push notifications capability is enabled for the app target only.
  • I added UNNotificationExtensionCategory and NSExtensionPointIdentifier. Also Im sending the category as part of the push payload from the server.

正如我所说,我收到通知但从未通过扩展名。我看到操作系统如何尝试加载扩展程序,然后抛出一个没有相关描述的错误来识别问题:

As I said, I get the notification but never goes through the extension. I see how the OS tries to load the extension but then throws an error with no relevant description to identify the problem:

Dec 31 21:00:00 iPhone SpringBoard(libextension.dylib)[51] <Notice>: calling plugIn beginUsing:   
Dec 31 21:00:57 iPhone pkd[86] <Notice>: assigning plug-in com.test.app.NotificationWithAttachmentExtension(1.0) to plugin sandbox   
Dec 31 21:03:57 iPhone pkd[86] <Notice>: enabling pid=51 for plug-in com.test.app.NotificationWithAttachmentExtension(1.0) 38BB5FF1-2597-42E0-B950-169DBFA80573 /private/var/containers/Bundle/Application/A8C47706-C0EC-4FB1-ABA7-0118372F6900/testapp.app/PlugIns/NotificationWithAttachmentExtension.appex   
Dec 31 21:00:53 iPhone SpringBoard(PlugInKit)[51] <Notice>: plugin com.test.app.NotificationWithAttachmentExtension interrupted   
Dec 31 21:03:56 iPhone SpringBoard(PlugInKit)[51] <Notice>: Hub connection error Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.test.app.NotificationWithAttachmentExtension" UserInfo={NSDebugDescription=connection to service named com.test.app.NotificationWithAttachmentExtension}   
Jun 29 13:33:36 iPhone SpringBoard(libextension.dylib)[51] <Notice>: PlugInKit error in beginUsing:   
Jun 17 23:33:04 iPhone SpringBoard(libextension.dylib)[51] <Notice>: killing invalid plugIn   
Dec 31 21:00:00 iPhone SpringBoard(UserNotificationsServer)[51] <Error>: Extension error whilst trying to modify push notification F502-9B36: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.test.app.NotificationWithAttachmentExtension" UserInfo={NSDebugDescription=connection to service named com.test.app.NotificationWithAttachmentExtension}   
Dec 31 21:00:00 iPhone SpringBoard(UserNotificationsServer)[51] <Notice>: [com.test.app] Saving notification F502-9B36   
Dec 31 21:00:00 iPhone SpringBoard(libextension.dylib)[51] <Notice>: completed calling plugIn beginUsing: for pid: 0  

相关扩展名.plist:

  <dict>
    <key>NSExtensionAttributes</key>
    <dict>
      <key>UNNotificationExtensionCategory</key>
      <string>attachmentCategory</string>
      <key>UNNotificationExtensionInitialContentSizeRatio</key>
      <real>1</real>
    </dict>
        <key>NSExtensionPointIdentifier</key>
        <string>com.apple.usernotifications.service</string>
        <key>NSExtensionPrincipalClass</key>
        <string>$(PRODUCT_MODULE_NAME).NotificationService</string>
  </dict>

有什么问题或遗失?

谢谢提前

推荐答案

最后我的工作正常,这是我在这个问题上记得的。

Finally I have this working correctly, and this is what I remember from this issue.

1)不要使用iOS10测试版的设备,因为我遇到的问题之一是因为我使用的是测试版。

1) Do not use devices with iOS10 beta version, because one of the problems I had was because I was using a beta version.

2)只有应用程序需要APNS权利,这对于用于扩展的私有化不是必需的。

2) only the app requres APNS entitlements, this is not required for the privisoning used for the extension.

3)我使用的配置文件匹配了扩展(不是通配符),无论如何我无法通过通配符确认它是否正常工作。

3) I was using a provisioning profile matching the id of the extension (not wildcard), anyway I cannot confirm if it works fine or not with wildcard.

4) NSExtensionAttributes不是必需的,只需使用NSExtensionPointIdentifier和NSExtensionPrincipalClass作为扩展名.plist。除非您使用自己的布局

4) NSExtensionAttributes are not required, just use NSExtensionPointIdentifier and NSExtensionPrincipalClass for the extension .plist. Unless you are using your own layout

5)即使使用iOS 9令牌注册方法也是如此。

5) This is working even using iOS 9 token registration methods.

6)不要忘记推送通知中的有效负载中的可变内容值,这是服务器通过扩展所需的唯一强制值。

6) don't forget mutable-content value in the payload coming in the push notification, this is the only mandatory value you need from the server to go through the extension.

我认为这涵盖了我遇到的所有问题

I think this covers all the problems I had

这篇关于未调用iOS10 UNNotificationServiceExtension的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆