我正在设计一个注册自己的UTI的应用程序。当另一个开发人员的应用共享此类型的文件时,他们怎么知道肯定是我的应用已打开?
目前,共享应用程序“ UIActivityItemSource”中返回的活动类型为“ com.apple.UIKit.activity.RemoteOpenInApplication-ByCopy”。
例如,如果它是Notes应用程序,则活动类型为“ com.apple.mobilenotes.SharingExtension”。如何注册共享应用可以接收的唯一活动类型?
/*
Example of how the other developers would be sharing data to my app
after calling UIActivityViewController with this OtherDevelopersAppActivityItemSource
*/
class OtherDevelopersAppActivityItemSource: NSObject, UIActivityItemSource {
func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivityType?) -> Any?
{
guard let _activityType = activityType else { return nil }
// this is probably my app that the user has selected??
if _activityType.rawValue == "com.apple.UIKit.activity.RemoteOpenInApplication-ByCopy" {
return "a large amount of data from the other developers app for my app"
}
else {
return nil
}
}
}
我希望activityType变量为'com.mycompany.myapp'或指定已选择哪个应用程序的内容。