我使用通知服务扩展来修改用户通知的内容,特别是本地化其内容以及声音文件。
这按预期工作,扩展只是继承系统语言。自 iOS 13 起,可以在应用程序的设置中设置应用程序特定的首选语言。然而,在这种情况下,服务扩展会忽略首选语言并仍然使用系统语言。
这是一个错误吗?或者我做错了什么?我可以通过解决方法来克服这个问题,但我想应该有一种合法的方法来实现这一点。
在这篇文章之后,我尝试在我的消息应用程序中实现共享表建议。
我已INSendMessageIntent在我的共享扩展的info.plist.
它甚至出现在“支持的意图”下的目标中。
但每次我捐赠时都会INSendMessageIntent失败,说不INSendMessageIntent支持。
错误域=IntentsErrorDomain代码=1901“此扩展不支持捐赠意图'INSendMessageIntent'。请确保您通过在其Info.plist中包含NSUserActivityTypes键来声明您的应用程序支持的意图,或者您的应用程序包含一个Intents扩展支持这一意图。”
// Create an INSendMessageIntent to donate an intent for a conversation with Juan Chavez.
let groupName = INSpeakableString(spokenPhrase: "Juan Chavez")
let sendMessageIntent = INSendMessageIntent(recipients: nil,
content: nil,
speakableGroupName: groupName,
conversationIdentifier: "sampleConversationIdentifier",
serviceName: nil,
sender: nil)
// Add the user's avatar to the intent.
let image = INImage(named: "Juan Chavez")
sendMessageIntent.setImage(image, forParameterNamed: \.speakableGroupName)
// Donate the intent.
let interaction = INInteraction(intent: sendMessageIntent, response: nil) …Run Code Online (Sandbox Code Playgroud) I\xe2\x80\x99m 为通知服务扩展创建应用程序 ID
\n\n我需要为其添加任何功能吗?\n其唯一目的是下载通知图像。我认为我不需要\xe2\x80\x99。
\n\n目前,我可以在不启用 Xcode 中任何功能的情况下构建到我的设备中。尽管当我查看 Xcode 自身构建的配置文件时,我看到钥匙串共享已启用。
\n\n我还看到了本教程,该教程与启用“应用程序组”有关。\n其他教程涉及启用应用程序组和推送通知。我认为我不需要应用程序组,因为我不需要传递任何值,只需更新通知即可。
\n\n我在文档中没有找到任何提到正确方法的内容。一位朋友告诉我,他在没有启用任何功能的情况下就开始工作,所以我很困惑。
\nxcode ios provisioning-profile ios-app-extension notification-service-extension
我正在开始开发 2 个应用程序扩展,我想按如下方式设置我的构建:
目前,我对每个项目都有不同的构建配置,以显示和隐藏应用程序的其他方面(在某些情况下也包括编译器标志)。我使用 fastlane 来进行构建。
据我所知,添加或删除应用程序扩展的唯一方法是:
有人能想出更好的解决方案来有条件地包含应用程序扩展吗?
xcode conditional-compilation xcodebuild ios-app-extension fastlane
我们可以在viewdidload中创建像此代码一样的自定义键盘,如Apple开发者网站所示.
self.nextKeyboardButton = [UIButton buttonWithType:UIButtonTypeSystem];
[self.nextKeyboardButton setTitle:NSLocalizedString(@"Next Keyboard", @"Title for 'Next Keyboard' button") forState:UIControlStateNormal];
[self.nextKeyboardButton sizeToFit];
self.nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.nextKeyboardButton addTarget:self action:@selector(advanceToNextInputMode) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.nextKeyboardButton];
NSLayoutConstraint *nextKeyboardButtonLeftSideConstraint = [NSLayoutConstraint constraintWithItem:self.nextKeyboardButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0];
NSLayoutConstraint *nextKeyboardButtonBottomConstraint = [NSLayoutConstraint constraintWithItem:self.nextKeyboardButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0];
[self.view addConstraints:@[nextKeyboardButtonLeftSideConstraint, nextKeyboardButtonBottomConstraint]];
Run Code Online (Sandbox Code Playgroud)
但是,有1个问题.当我们以纵向运行该程序时,自定义键盘的高度约为220.然后我们改为横向.它小于220.奇怪的是,当我回到纵向视图时,高度不再是220,它与景观高度相同.它永远不会回到原来的高度.那么,有没有办法改变我们将添加子视图的视图高度?
我已经添加today extension到我的应用程序(仅用于测试),现在,我想删除它.我已经尝试删除所有似乎与扩展程序相关联的文件,但是当我再次运行应用程序时,今天的通知视图中仍然可以使用扩展程序...任何人都可以帮我删除它吗?非常感谢!
我正在为ios 8创建自定义键盘.像这样创建键盘按钮
UIButton *aBtn = [ UIButton buttonWithType:UIButtonTypeCustom ];
[aBtn setFrame:CGRectMake(x, 30, btnWidth, btnHeight)];
[aBtn setImage:[UIImage imageNamed:@"A"] forState:UIControlStateNormal];
[aBtn setTitle:@"A" forState:UIControlStateNormal];
[aBtn setTitleColor:[ UIColor blackColor] forState:UIControlStateNormal];
[aBtn setTitleColor:[ UIColor whiteColor] forState:UIControlStateHighlighted];
[aBtn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:aBtn];
Run Code Online (Sandbox Code Playgroud)
我的问题是图像没有设置为按钮.我怎么解决这个问题?
我是否需要任何特殊步骤才能将图像添加到Xcode以获取自定义键盘?
我想在今日扩展中使用NSTimer来刷新小部件,但我不知道剂量这种行为是否合法?
我做了一个演示使用NSTimer来计算并每1秒刷新一次窗口小部件UI,看起来像是工作,但问题是当用户退出通知中心时,计时器仍在运行,何时何地应该停止计时器?
我目前正在开发包含Share扩展的iOS应用程序.
我意识到
NSExtensionActivationSupportsImageWithMaxCount密钥不允许我在Safari下的.jpeg或.png URL("public.image"UTI,kUTTypeImage)上激活我的Share扩展(即:一个imgur链接).
如果我切换到NSActivationRule = TRUEPREDICATE,我仍然可以激活并测试我的扩展,但禁止发布的应用程序.
我填写了一个关于雷达的错误,如果它不被通缉(甚至facebook,twitter等...都没有在这个URL上激活)
现在,我想将下面的键和"public.image"结合在NSPredicate字符串中,如文档所述(https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios .html#// apple_ref/doc/uid/TP40014214-CH21-SW8)
所以我必须将密钥翻译成UTI
到目前为止,我已翻译:
- NSExtensionActivationSupportsFileWithMaxCount"public.file-url" kUTTTypeFileURL
- NSExtensionActivationSupportsMovieWithMaxCount"public.movie" kUTTypeMovie
- NSExtensionActivationSupportsText"public.text" kUTTypeText
- NSExtensionActivationSupportsWebURLWithMaxCount"public.url"kUTTypeURL
但我找不到类型翻译:
NSExtensionActivationSupportsWebPageWithMaxCount,"public.HTML"是kUTTypeHTML吗?有人已经在谓词中使用了这个键吗?
iOS上的键盘扩展是类的子UIInputViewController类,并具有textDocumentProxy与底层文档交互的属性.该textDocumentProxy对象公开了文档的一些重要特征,如自动资本化类型.问题是,键盘扩展如何知道基础文档何时发生变化?
例如,当我点击在消息应用程序中撰写新消息时,"收件人"字段使用与消息正文输入框不同的输入特征.但是,由于在将焦点从一个字段切换到另一个字段时键盘不会消失,因此文本文档代理对象即时更改.键盘扩展可以注意到这样的变化吗?
我试过通过KVO 观察textDocumentProxy和[[self textDocumentProxy] autocapitalizationType]属性,但这不起作用.autocapitalizationType使用计时器检查属性会显示更改,但显然我想避免使用轮询解决方案.
ios ×8
ios8 ×3
xcode ×2
autolayout ×1
fastlane ×1
ios13 ×1
iphone ×1
keyboard ×1
notification-service-extension ×1
swift ×1
xcodebuild ×1