Extensions

RSS for tag

Give users access to your app's functionality and content throughout iOS and macOS using extensions.

Posts under Extensions tag

200 Posts

Post

Replies

Boosts

Views

Activity

OSLogStore can't access an app's extensions?
I've got an iOS app with lots of extensions, some of them complex and doing a lot of stuff. After a bug I'd like to be able to use OSLogStore to get a holistic picture of logging for the app and its extensions and send that to a debugging server to retrospectively view logs for the app and its extensions. The constructor is OSLogStore.init(scope: OSLogStore.Scope), however scope only has one value .currentProcessIdentifier. Implying if that is called from within the app it can only get access to logging for its process only. I tried it out to confirm this is the case - if I log something in an extension (using Logger), then run the app with code like this:  let logStore = try! OSLogStore(scope: .currentProcessIdentifier)  let oneHourAgo = logStore.position(date: Date().addingTimeInterval(-3600)) let allEntries = try! logStore.getEntries(at: oneHourAgo)       for entry in allEntries { look at the content of the entry Then none of the entries are from the extension. Is there anyway from within the app I can access logging made within an extension?
4
0
950
Apr ’25
Notification displayed via Notification Service Extension doesn't display correctly if the iPhone is passcode protected and locked
I've got a notification service extension which is working as expected unless the user a) turns the passcode for the iPhone on and b) turns on Auto-lock and the iPhone is locked when a push arrives If auto-lock is turned on and the phone is locked but passcode is not turned on, then the notification is displayed as expected. The iPhone displays a notification with the top line being the name of the app and the second line saying "Notification", which is neither the content within the push payload, not what is being set as the content within the extension. There's no difference in behaviour of the extension when passcode is enabled. Adding logging to the extension I can confirm the content is being replaced and posted as expected: NSLog("Going to post notification title: \(notificationContent.title) subtitle: \(notificationContent.subtitle) body: \(notificationContent.body)") contentHandler(notificationContent) The notificationContent is as expected and is identical when passcode is on off. Why is the iPhone displaying the notification incorrectly if passcode is turned on and the phone locked?
3
0
1.1k
Jan ’22
Hide Share extension from UIActivityViewController when user selects a directory
I'm looking to hide my app extension from the UIActivityViewController when a user selects a directory. I have tried through specifying the dictionary on NSExtensionActivationRule with the available keys, but it seems that there is no key that considers directories: NSExtensionActivationSupportsAttachmentsWithMaxCount NSExtensionActivationSupportsAttachmentsWithMinCount NSExtensionActivationSupportsFileWithMaxCount NSExtensionActivationSupportsImageWithMaxCount NSExtensionActivationSupportsMovieWithMaxCount NSExtensionActivationSupportsText NSExtensionActivationSupportsWebURLWithMaxCount NSExtensionActivationSupportsWebPageWithMaxCount As an alternative I'm using the string option, providing the following predicate that considers up to 5 files, 5 images, 1 video and 0 directories: SUBQUERY ( extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" ).@count <= 1 AND SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ).@count <= 5 AND SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" ).@count <= 5 AND SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.directory" ).@count == 0 ).@count >= 0 The predicate works for the video, image and file limitations, but when it comes to directories, the extension keeps appearing. Is there any way to achieve this?
0
0
680
Jan ’22
Null popup
I got this message on an apple computer while using Firefox. "Null" would like to filter and monitor network content. I hit accept. Then I started to second guess myself. So I ran a free version of malware bytes. Do you think my computer is okay? Should I be worried I've been hacked?
0
0
375
Jan ’22
Potential Privacy Information Leak Risk in Share Extension
Using this method from iOS 8 to iOS 15, no matter whether the team identifier of the share source and the share target are the same, the share source can get the bundle identifier of the share target, so there is a risk of leakage, and it is recommended to fix it. It has been found that many apps use this method to obtain private information, such as ShareExtension in WeChat #ifdef HIDE_POST_DIALOG - ( void ) willMoveToParentViewController: ( UIViewController * ) parent { // This is called at the point where the Post dialog is about to be shown. NSString * hostBundleID = [parent valueForKey:(@"_hostBundleID")]; NSLog( @"**** parent bundle id is %@" ,hostBundleID); } #endif https://stackoverflow.com/questions/28453044/how-to-get-bundleid-of-the-source-app-when-using-share-extension-in-ios8/38262999#38262999
1
0
839
Jan ’22
EXC_BAD_ACCESS upon UI extensions startup
Hello everyone, we are developing an extension with user interface presented, it works correctly with iOS 15, but crashes upon startup on devices with iOS 14. To my understanding, the presented log implies that crash occurs before the extension's code is executed, so we can't fix the code itself to solve the issue. Maybe it is possible to find out what might be the cause? Crash log
1
0
933
Nov ’22
NetworkExtension Code signature validation failed fatally
I am currently unable to install on MacOSX due to the following error. My app structure is as follows. There are two groups, one is installed and one that installs with an additional extension (connected by plug-in) is not installed. SystemExtension and NetworkExtension are installed as extensions in the first to be installed, and NetworkExtension and endpoint security are installed in the second connected to a plug-in. Also, during the installation, I checked the following error in the kernel. "Code has restricted entitlements, but the validation of its code signature failed." And on the Apple Developer site, I'm registered as a team and I'm using Xcode13 to auto-sign everyone. When I compared entitlement and embedded.provisionprofile, I didn't find anything unusual. [entitlement] [Key] com.apple.application-identifier [Value] [String] teamid.com.example.TestAPP.Extension [Key] com.apple.developer.endpoint-security.client [Value] [Bool] true [Key] com.apple.developer.networking.networkextension [Value] [Array] [String] content-filter-provider [Key] com.apple.developer.team-identifier [Value] [String] teamid [Key] com.apple.security.get-task-allow [Value] [Bool] true [embedded.provisionprofile] <key>com.apple.developer.networking.networkextension</key> <array> <string>app-proxy-provider</string> <string>content-filter-provider</string> <string>packet-tunnel-provider</string> <string>dns-settings</string> </array> <key>com.apple.application-identifier</key> <string>teamid.com.example.TestAPP.Extension</string> <key>keychain-access-groups</key> <array> <string>teamid.*</string> </array> <key>com.apple.developer.team-identifier</key> <string>teamid</string> Also, it turns out that I haven't set the value for endpoint-security.client correctly, but this isn't confirmed where to set it in apple developer site.
0
0
622
Jan ’22
Why do i get this error to conform a view
// //  ContentView.swift //  shop // //  Created by Cloud Patel on 26/12/21. // import SwiftUI     func trying()     {         for el in clothimages         {             print(el)         }     } struct ContentView: View {     var clothimages:[UIImage] =         [UIImage(named:"menjacket")!,         UIImage(named:"menjeans")!,         UIImage(named:"mentshirt")!]     var body: some View {              NavigationView{                               ScrollView{                      Text("Men")                          .font(.system(size: 30, weight:.bold))                      .padding(.trailing, 320.0)                  ScrollView(.horizontal){                      HStack{ //this is where I get error //Type '()' cannot conform to 'View'                                                    trying() //                         custom(content:Image("mentshirt"),over:"T-shirt",col: .black) //                         custom(content:Image("menjeans"),over:"Jeans",col: .black) //                         custom(content:Image("menjacket"),over: "Jacket",col: .black)                      }                  }                      Text("Women")                          .font(.system(size: 30,weight: .bold))                          .padding(.trailing,280.0)                  ScrollView(.horizontal){                      HStack{                          custom(content:Image("womentshirt"),over:"T-shirt",col: .black)                          custom(content:Image("womenjeans"),over:"Jeans",col: .black)                          custom(content:Image("womenjacket"),over:"Jacket",col: .black)                      }                  }                      Text("Kids")                          .font(.system(size: 30,weight: .bold))                          .padding(.trailing,320.0)                  ScrollView(.horizontal){                      HStack{                          NavigationLink(destination:login()){                              custom(content:Image("kidtshirt"),over:"T-shirt",col:.black)                      }                          custom(content:Image("kidjeans"),over:"Jeans",col: .black)                          custom(content:Image("kidjacket"),over:"Jacket",col:.black)                      }                  }                  }                  .navigationBarItems(leading:                                          NavigationLink(                                          destination: edit()){                                                  navcustom(content:                                                             Image(systemName: "line.horizontal.3"),col: .white)                          },                      trailing:                              HStack{                      navcustom(content:                                 Image(systemName: "indianrupeesign.circle.fill"),col: .white)                              Spacer(minLength: 80)                          NavigationLink(destination: cart()){                              navcustom(content:                                         Image(systemName: "cart"),col: .white)                          }                          Spacer(minLength: 15)                              NavigationLink(destination: logger()){                                  navcustom(content:Image(systemName: "person.crop.circle.fill"), col: .white)                              }                          }                  )              }                       } }                                           func logger() -> some View{         var userlogg=false         if userlogg{             return AnyView(settings())         }         else{             return AnyView(login())         }     }          struct ContentView_Previews: PreviewProvider {     static var previews: some View {         Group {               ContentView() //                .environment(.colorScheme, .dark)         }     } } func custom(content:Image,over:String,col:Color) -> some View {     content         .resizable()         .overlay(Text(over).font(.system(size: 20,weight: .bold)).foregroundColor(col),alignment: .bottomLeading)         .frame(width: 400, height: 500, alignment: .center)         .padding(5)                        } func navcustom(content:Image,col:Color)-> some View {     content         .resizable()         .frame(width: 30, height: 30, alignment: /@START_MENU_TOKEN@/.center/@END_MENU_TOKEN@/)         .foregroundColor(col) } //class watchlog:ObservableObject{ //    @Published var userlogg=false //} //struct logging{ //    func logger() -> some View{ //        var userlogg=true //        if userlogg{ //            return AnyView(settings()) //        } //        else{ //            return AnyView(login()) //        } //    } //} // even if I use the function a structure I get this error struct nonsense:View{     var body: some View     {         func trying(). //Closure containing a declaration cannot be used with result builder 'ViewBuilder'         {             for el in clothimages             {                 print(el)             }         }     } }
0
0
557
Jan ’22
Is it possible to improve Access Control?
Hey guys I think a lot of developers will be happy :) If in Access Control also will be like "extensionprivate" Wait!, what does it mean "extensionprivate" :) Let me describe Currently we have Open access Internal access File-private access Private access also I'm suggesting to add Extension private This is cool because you can add a "extension-private" property that will only be visible in the extension.
0
0
391
Jan ’22
For the same file types, on Share Sheet, some apps show my app and some apps don't
My app is shown on share sheet when I try sharing PDFs or Images from apps like Box, Doximity and DropBox etc. But some apps like Google Drive does not show my app on Share Sheet. Even the "More" button or Edit actions would not show my app.  Screenshot is here: https://imgur.com/a/z94OG5l I have necessary items listed on plist file - NSExtensionActivationSupportsFileWithMaxCount and NSExtensionActivationSupportsImageWithMaxCount What would be the reason why some apps show and some don't? How do I fix it?
0
0
898
Jan ’22
iOS Share Extension + NSFetchedResultsController not returning results
I am sharing my CoreData model between my iOS main app target and a new Share Extension target like this post:  This is working well for the most part except for one thing.  NSFetchedResultsController is not returning results when called from the Shared Extension. What is strange though is that if I do a plain NSFetchRequest in my Share Extension, I do get CoreData results returned that were originally saved from the main app...so I think Container setup as well as model must be being shared correctly via AppContainer. NSFetchedResultsControllerDelegate controllerDidChangeContent is never called. Any ideas or suggestions? import UIKit import MobileCoreServices class ShareViewController: UIViewController { private(set) lazy var resultsController: NSFetchedResultsController<Person> = createFetchedResultsController() override func viewDidLoad() { super.viewDidLoad() let fetchRequest = NSFetchRequest<Person>(entityName: "Person") fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] do { /// this works! let persons = try CoreDataManager.shared.managedObjectContext.fetch(fetchRequest) print("Got \(persons.count) Persons") } catch { print("Fetch failed") } activateResultsController() } func createFetchedResultsController() -> NSFetchedResultsController<Person> { CoreDataManager.shared.container.viewContext.stalenessInterval = 0 CoreDataManager.shared.container.viewContext.refreshAllObjects() CoreDataManager.shared.container.viewContext.stalenessInterval = -1 let fetchRequest = NSFetchRequest<Person>(entityName: "Person") fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] ////managedObjectContext: CoreDataManager.shared.managedObjectContext, let controller = NSFetchedResultsController( fetchRequest: fetchRequest, managedObjectContext: CoreDataManager.shared.managedObjectContext, sectionNameKeyPath: nil, cacheName: nil ) controller.delegate = self return controller } private func activateResultsController() { do { try resultsController.performFetch() } catch { fatalError("Failed to fetch entities: \(error)") } } } // MARK: - Results Controller Delegate extension ShareViewController: NSFetchedResultsControllerDelegate { func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) { guard let sections = resultsController.sections else { return } let section = sections[0] let rows = section.numberOfObjects print("rows=\(rows)") } } import UIKit import CoreData class CoreDataManager { static let shared = CoreDataManager() internal var container: NSPersistentContainer var managedObjectContext: NSManagedObjectContext { container.viewContext } init() { container = NSPersistentContainer(name: Constants.name) guard let storeDirectory = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first else { // We'll throw a fatalError() because we can't really proceed without storeDirectory fatalError(file: "Could not find .applicationSupportDirectory - exiting") } let storeURL = storeURL(for: "group.mygroup.testshareextensioncoredata", databaseName: "\(Constants.name)") let storeDescription = NSPersistentStoreDescription(url: storeURL) container.persistentStoreDescriptions = [storeDescription] container.loadPersistentStores(completionHandler: { storeDescription, error in if let error = error as NSError? { // We'll throw a fatalError() because we can't really proceed without loading the PersistentStore fatalError("loadPersistentStore failed \(error), \(error.userInfo)") } }) } // MARK: - Core Data Saving support func saveContext() { managedObjectContext.performAndWait { if managedObjectContext.hasChanges { do { try managedObjectContext.save() } catch { } } } } /// Returns a URL for the given app group and database pointing to the sqlite database. func storeURL(for appGroup: String, databaseName: String) -> URL { guard let fileContainer = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroup) else { fatalError("Shared file container could not be created.") } return fileContainer.appendingPathComponent("\(databaseName).sqlite") } } internal extension CoreDataManager { enum Constants { static let name = "ShareExtensionCoreDataTest" } }
3
0
1.9k
Jun ’22
Non existent files shown in files app
I have a files provider app that seems to be working perfectly except for one thing. If I have a directory open in the files provider app and then put the app into the backround and while in the background a file is renamed in the open directory via some other app, then when the files app comes back into the foreground it shows the file with the old name as well as the new name. I can see via logging that the FileproviderEnumerator is being closed when the app is moved to the background and then reopened when it is moved back into the foreground and I can also see that the correct file names are loaded into it when enumerating. It looks like the files app doesn't check to see if what it currently has in its cache matches what was just loaded and remove anything that is missing. To make it more confusing this only appears to be a problem on some devices and not others. It is a problem on my iPad running iPadOS 15.2.1. I have tried having the parent app, which did the file rename send a change notification but that doesn't seem to work either. If I call the following in my app: [NSFileProviderManager.defaultManager signalEnumeratorForContainerItemIdentifier:identifier completionHandler:^(NSError * _Nullable error){ if (error != nil) NSLog(@"signalEnumeratorForContainerItemIdentifier error:%@", error); else { NSLog(@"signalEnumeratorForContainerItemIdentifier OK"); } }]; I see the following message in the console log from the fileproviderd: [DEBUG] Received error NSError: Cocoa 3072 "" while sending didChangeItemID:completionHandler: on behalf of myApp[955] Do I need to explicetly tell the files app when a file has been deleted or renamed?
0
0
1k
Jan ’22
iOS Share Extension gives non existent file URL
G'day, I'm working on a share extension for our iOS app where the users are able to select multiple photos or videos and choose to share it conversations inside the app. Similar to other chat apps are doing. I ran into a problem where the file URL extracted through the inputItem's attachment are non existent for some of the files. For example share extension gives file URL such as this, file:///var/folders/4r/qlw_jjvj3w7gh5mssgzhx15w0000gp/T/com.apple.Photos/ShareKit-Exports/2918015E-B07C-4F35-9D98-86B58464DE88/B699E8DE-4965-4C0F-9D9B-4956E5E02730/IMG_1234.jpg But there is no such file in that location. Instead there is a file named IMG_1234.png (or different file extension), for certain items in user's photo library. How does this happen? Am I supposed to query the files inside the parent directory and locate truely existing file from it by ignoring the returned file name or some other way. When the same file is shared from other apps such as airdrop, mail, notes, they seem to have no problem opening up this file and the saved file (e.g. from airdrop) has identical file name and properties (IMG_1234.png) at final destination. Below is code snippet on how I process the extension context in my share extension. // I'm getting first input item here, I've checked and there are no more than 1 input item for the affected assets that are causing problem guard let itemProviders = (extensionContext?.inputItems.first as? NSExtensionItem)?.attachments else { return } var items: [Attachment] = [] // Attachment is a custom type that contains file url or image data itemProviders.forEach { itemProvider in if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeImage as String) { let desiredTypeIdentifier: String = kUTTypeImage as String itemProvider.loadItem(forTypeIdentifier: desiredTypeIdentifier, options: nil) { data, _ in if let url = data as? URL { items.append(.init(data: .file(url))) // the URL returned above is incorrect for the affected items. It's reproducible every time. } else if let image = data as? UIImage { items.append(.init(data: .memory(image))) } } } } Regards,
0
0
1.5k
Jan ’22
Mouse input completely disabled in Password AutoFill App Extension in Safari
Hi, We are receiving complaints from some users about our Password AutoFill component on macOS. The issue usually presents itself after some time, but it's pretty severe. When a user chooses our App to AutoFill their passwords, usually in Safari, we present a sheet allowing them to search from and choose a particular credential to fill. This works pretty well most of the time. However, after continued use, users report that they can no longer interact with the sheet using the mouse. Keyboard events seem to be fine, they can navigate using the up and down keys, but any clicks are just not registered. We've asked users to look in the console and let us know if they see anything strange. We've got a report back that Console is filled with: invalid display identifier <private> Also, it's speculative but all reports appear to be users using a second external display and it may possibly be related to the Mac going to sleep and the issue occurs after waking up. The solution for our users is to terminate Safari, upon restart the issue is resolved until the next time it begins, sometime later. Is there anything we can do, have you heard of an issue like this before, what could possibly block mouse events after a long period of time? Is this an App Extension issue, a Safari issue, a presenting a Sheet from an App Extension inside Safari issue? Any help appreciated.
0
0
739
Feb ’22
Web extension website permissions handling seems weak
I have a web extension that needs to operate on several websites (in fact, it opens a tab and navigates through those websites). Apple's documentation says " Safari shows a badge next to your extension’s item that indicates the user needs to interact with the extension to grant it permission." I see no such badge next to my extension. If I hover over the extension icon, then I see the message "The extension 'xxx' would like access to additional websites" (Is this the badge referred to?) This is not obvious enough to the user (it took me two days to figure out that this is why my extension wasn't working). Further, when one is in the Safari Settings "Websites" tab to give permission to the extension, they must individually change the setting for each website (from "Ask" to "Allow") -- there is no "Allow all" option. How can I affect this process to make it less of a mystery to users and as easy as possible for them to grant me access?
0
0
661
Feb ’22
Banner of local notification from broadcast upload extension may not work.
Hi. I implemented a broadcast upload extension and it requests local notifications. The local notification works normally on broadcastStarted(withSetupInfo:), but the Banner of the local notification does not work on processSampleBuffer(_: with:) though its Notification Center works normally. What am I missing? Here is my code snippets. container app class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. requestAuthorization() ... } private func requestAuthorization() { let center = UNUserNotificationCenter.current() center.requestAuthorization(options: [.alert]) { granted, error in if let error = error { // Handle the error here. print(error) } if granted == true { center.delegate = self center.getNotificationSettings(completionHandler: { setting in print(setting) }) } else { print("not permitted") } } } } upload extension class SampleHandler: RPBroadcastSampleHandler { override func broadcastStarted(withSetupInfo setupInfo: [String : NSObject]?) { super.broadcastStarted(withSetupInfo: setupInfo) notification(title: "Upload Extension", body: "broadcastStarted") ... } override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) { super.processSampleBuffer(sampleBuffer, with: sampleBufferType) ... if some condition { notification(title: "Upload Extension", body: "processSampleBuffer") } } private func notification(title: String, body: String) { let content = UNMutableNotificationContent() content.title = title content.body = body let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil) let notificationCenter = UNUserNotificationCenter.current() notificationCenter.add(request) { error in if error != nil { print(error) } } } }
3
0
2.6k
Jun ’23
macOS 12.2 FileProviderExtension won't be loaded
Hi, I am new to macOS development. I am trying to develop macOS FileProvider extension, and everything was fine until I updated my macOS from 11 to 12.2. After updating OS, FileProvider extension won't being loaded by NSFileProviderManager.add(domain) and its completion handler returns error - NSFileProviderDomain.Error.providerNotFound @IBAction func tapAddDomainButton(_ sender: Any) { NSFileProviderManager.add(domain) { error in print("Add domain error: \(error)") // <- Error: Optional(Error Domain=NSFileProviderErrorDomain Code=-2001 "The application cannot be used right now." UserInfo={NSLocalizedDescription=The application cannot be used right now.}) } } I've made a new boilerplate project with default macOS > App + 'File Provider Extension' in Xcode, and still got same error. Same code works on macOS 11.6.1 Weird thing is that apple sample code won't return error and still works in macOS 12.2. I can't find any difference between my code and apple sample. Apple Sample Code I uploaded my test project here. Please help Thanks in advance.
3
0
2.5k
Feb ’22
Trash character in webview's textfield
Using iOS keyboard extension, I want to move the caret to first of strings in textfield. So, I try to get the string before cursor, and move cursor. The offset is the text length, like below. The textfield's text in safari(apple.com search field) is "abcd". But, the return value is " abcd" including space character at first. So, the cursor does not move because the length(length 5) is exceeded the real text length(length 4). This is definitely appeared independently of iOS versions. guard let text = textDocumentProxy.documentContextBeforeInput else {       return     }           print("text(\(text)) = \(text.count)")           textDocumentProxy.adjustTextPosition(byCharacterOffset: -text.count)
0
0
575
Feb ’22
OSLogStore can't access an app's extensions?
I've got an iOS app with lots of extensions, some of them complex and doing a lot of stuff. After a bug I'd like to be able to use OSLogStore to get a holistic picture of logging for the app and its extensions and send that to a debugging server to retrospectively view logs for the app and its extensions. The constructor is OSLogStore.init(scope: OSLogStore.Scope), however scope only has one value .currentProcessIdentifier. Implying if that is called from within the app it can only get access to logging for its process only. I tried it out to confirm this is the case - if I log something in an extension (using Logger), then run the app with code like this:  let logStore = try! OSLogStore(scope: .currentProcessIdentifier)  let oneHourAgo = logStore.position(date: Date().addingTimeInterval(-3600)) let allEntries = try! logStore.getEntries(at: oneHourAgo)       for entry in allEntries { look at the content of the entry Then none of the entries are from the extension. Is there anyway from within the app I can access logging made within an extension?
Replies
4
Boosts
0
Views
950
Activity
Apr ’25
Notification displayed via Notification Service Extension doesn't display correctly if the iPhone is passcode protected and locked
I've got a notification service extension which is working as expected unless the user a) turns the passcode for the iPhone on and b) turns on Auto-lock and the iPhone is locked when a push arrives If auto-lock is turned on and the phone is locked but passcode is not turned on, then the notification is displayed as expected. The iPhone displays a notification with the top line being the name of the app and the second line saying "Notification", which is neither the content within the push payload, not what is being set as the content within the extension. There's no difference in behaviour of the extension when passcode is enabled. Adding logging to the extension I can confirm the content is being replaced and posted as expected: NSLog("Going to post notification title: \(notificationContent.title) subtitle: \(notificationContent.subtitle) body: \(notificationContent.body)") contentHandler(notificationContent) The notificationContent is as expected and is identical when passcode is on off. Why is the iPhone displaying the notification incorrectly if passcode is turned on and the phone locked?
Replies
3
Boosts
0
Views
1.1k
Activity
Jan ’22
Hide Share extension from UIActivityViewController when user selects a directory
I'm looking to hide my app extension from the UIActivityViewController when a user selects a directory. I have tried through specifying the dictionary on NSExtensionActivationRule with the available keys, but it seems that there is no key that considers directories: NSExtensionActivationSupportsAttachmentsWithMaxCount NSExtensionActivationSupportsAttachmentsWithMinCount NSExtensionActivationSupportsFileWithMaxCount NSExtensionActivationSupportsImageWithMaxCount NSExtensionActivationSupportsMovieWithMaxCount NSExtensionActivationSupportsText NSExtensionActivationSupportsWebURLWithMaxCount NSExtensionActivationSupportsWebPageWithMaxCount As an alternative I'm using the string option, providing the following predicate that considers up to 5 files, 5 images, 1 video and 0 directories: SUBQUERY ( extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" ).@count <= 1 AND SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ).@count <= 5 AND SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" ).@count <= 5 AND SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.directory" ).@count == 0 ).@count >= 0 The predicate works for the video, image and file limitations, but when it comes to directories, the extension keeps appearing. Is there any way to achieve this?
Replies
0
Boosts
0
Views
680
Activity
Jan ’22
Null popup
I got this message on an apple computer while using Firefox. "Null" would like to filter and monitor network content. I hit accept. Then I started to second guess myself. So I ran a free version of malware bytes. Do you think my computer is okay? Should I be worried I've been hacked?
Replies
0
Boosts
0
Views
375
Activity
Jan ’22
Potential Privacy Information Leak Risk in Share Extension
Using this method from iOS 8 to iOS 15, no matter whether the team identifier of the share source and the share target are the same, the share source can get the bundle identifier of the share target, so there is a risk of leakage, and it is recommended to fix it. It has been found that many apps use this method to obtain private information, such as ShareExtension in WeChat #ifdef HIDE_POST_DIALOG - ( void ) willMoveToParentViewController: ( UIViewController * ) parent { // This is called at the point where the Post dialog is about to be shown. NSString * hostBundleID = [parent valueForKey:(@"_hostBundleID")]; NSLog( @"**** parent bundle id is %@" ,hostBundleID); } #endif https://stackoverflow.com/questions/28453044/how-to-get-bundleid-of-the-source-app-when-using-share-extension-in-ios8/38262999#38262999
Replies
1
Boosts
0
Views
839
Activity
Jan ’22
EXC_BAD_ACCESS upon UI extensions startup
Hello everyone, we are developing an extension with user interface presented, it works correctly with iOS 15, but crashes upon startup on devices with iOS 14. To my understanding, the presented log implies that crash occurs before the extension's code is executed, so we can't fix the code itself to solve the issue. Maybe it is possible to find out what might be the cause? Crash log
Replies
1
Boosts
0
Views
933
Activity
Nov ’22
Unable to use view debugger for share extension
When try to use view debugger on share extension, it only shows a blank placeholder view and not my share extension UI, is his supported?
Replies
0
Boosts
0
Views
709
Activity
Jan ’22
NetworkExtension Code signature validation failed fatally
I am currently unable to install on MacOSX due to the following error. My app structure is as follows. There are two groups, one is installed and one that installs with an additional extension (connected by plug-in) is not installed. SystemExtension and NetworkExtension are installed as extensions in the first to be installed, and NetworkExtension and endpoint security are installed in the second connected to a plug-in. Also, during the installation, I checked the following error in the kernel. "Code has restricted entitlements, but the validation of its code signature failed." And on the Apple Developer site, I'm registered as a team and I'm using Xcode13 to auto-sign everyone. When I compared entitlement and embedded.provisionprofile, I didn't find anything unusual. [entitlement] [Key] com.apple.application-identifier [Value] [String] teamid.com.example.TestAPP.Extension [Key] com.apple.developer.endpoint-security.client [Value] [Bool] true [Key] com.apple.developer.networking.networkextension [Value] [Array] [String] content-filter-provider [Key] com.apple.developer.team-identifier [Value] [String] teamid [Key] com.apple.security.get-task-allow [Value] [Bool] true [embedded.provisionprofile] <key>com.apple.developer.networking.networkextension</key> <array> <string>app-proxy-provider</string> <string>content-filter-provider</string> <string>packet-tunnel-provider</string> <string>dns-settings</string> </array> <key>com.apple.application-identifier</key> <string>teamid.com.example.TestAPP.Extension</string> <key>keychain-access-groups</key> <array> <string>teamid.*</string> </array> <key>com.apple.developer.team-identifier</key> <string>teamid</string> Also, it turns out that I haven't set the value for endpoint-security.client correctly, but this isn't confirmed where to set it in apple developer site.
Replies
0
Boosts
0
Views
622
Activity
Jan ’22
Why do i get this error to conform a view
// //  ContentView.swift //  shop // //  Created by Cloud Patel on 26/12/21. // import SwiftUI     func trying()     {         for el in clothimages         {             print(el)         }     } struct ContentView: View {     var clothimages:[UIImage] =         [UIImage(named:"menjacket")!,         UIImage(named:"menjeans")!,         UIImage(named:"mentshirt")!]     var body: some View {              NavigationView{                               ScrollView{                      Text("Men")                          .font(.system(size: 30, weight:.bold))                      .padding(.trailing, 320.0)                  ScrollView(.horizontal){                      HStack{ //this is where I get error //Type '()' cannot conform to 'View'                                                    trying() //                         custom(content:Image("mentshirt"),over:"T-shirt",col: .black) //                         custom(content:Image("menjeans"),over:"Jeans",col: .black) //                         custom(content:Image("menjacket"),over: "Jacket",col: .black)                      }                  }                      Text("Women")                          .font(.system(size: 30,weight: .bold))                          .padding(.trailing,280.0)                  ScrollView(.horizontal){                      HStack{                          custom(content:Image("womentshirt"),over:"T-shirt",col: .black)                          custom(content:Image("womenjeans"),over:"Jeans",col: .black)                          custom(content:Image("womenjacket"),over:"Jacket",col: .black)                      }                  }                      Text("Kids")                          .font(.system(size: 30,weight: .bold))                          .padding(.trailing,320.0)                  ScrollView(.horizontal){                      HStack{                          NavigationLink(destination:login()){                              custom(content:Image("kidtshirt"),over:"T-shirt",col:.black)                      }                          custom(content:Image("kidjeans"),over:"Jeans",col: .black)                          custom(content:Image("kidjacket"),over:"Jacket",col:.black)                      }                  }                  }                  .navigationBarItems(leading:                                          NavigationLink(                                          destination: edit()){                                                  navcustom(content:                                                             Image(systemName: "line.horizontal.3"),col: .white)                          },                      trailing:                              HStack{                      navcustom(content:                                 Image(systemName: "indianrupeesign.circle.fill"),col: .white)                              Spacer(minLength: 80)                          NavigationLink(destination: cart()){                              navcustom(content:                                         Image(systemName: "cart"),col: .white)                          }                          Spacer(minLength: 15)                              NavigationLink(destination: logger()){                                  navcustom(content:Image(systemName: "person.crop.circle.fill"), col: .white)                              }                          }                  )              }                       } }                                           func logger() -> some View{         var userlogg=false         if userlogg{             return AnyView(settings())         }         else{             return AnyView(login())         }     }          struct ContentView_Previews: PreviewProvider {     static var previews: some View {         Group {               ContentView() //                .environment(.colorScheme, .dark)         }     } } func custom(content:Image,over:String,col:Color) -> some View {     content         .resizable()         .overlay(Text(over).font(.system(size: 20,weight: .bold)).foregroundColor(col),alignment: .bottomLeading)         .frame(width: 400, height: 500, alignment: .center)         .padding(5)                        } func navcustom(content:Image,col:Color)-> some View {     content         .resizable()         .frame(width: 30, height: 30, alignment: /@START_MENU_TOKEN@/.center/@END_MENU_TOKEN@/)         .foregroundColor(col) } //class watchlog:ObservableObject{ //    @Published var userlogg=false //} //struct logging{ //    func logger() -> some View{ //        var userlogg=true //        if userlogg{ //            return AnyView(settings()) //        } //        else{ //            return AnyView(login()) //        } //    } //} // even if I use the function a structure I get this error struct nonsense:View{     var body: some View     {         func trying(). //Closure containing a declaration cannot be used with result builder 'ViewBuilder'         {             for el in clothimages             {                 print(el)             }         }     } }
Replies
0
Boosts
0
Views
557
Activity
Jan ’22
Is it possible to improve Access Control?
Hey guys I think a lot of developers will be happy :) If in Access Control also will be like "extensionprivate" Wait!, what does it mean "extensionprivate" :) Let me describe Currently we have Open access Internal access File-private access Private access also I'm suggesting to add Extension private This is cool because you can add a "extension-private" property that will only be visible in the extension.
Replies
0
Boosts
0
Views
391
Activity
Jan ’22
For the same file types, on Share Sheet, some apps show my app and some apps don't
My app is shown on share sheet when I try sharing PDFs or Images from apps like Box, Doximity and DropBox etc. But some apps like Google Drive does not show my app on Share Sheet. Even the "More" button or Edit actions would not show my app.  Screenshot is here: https://imgur.com/a/z94OG5l I have necessary items listed on plist file - NSExtensionActivationSupportsFileWithMaxCount and NSExtensionActivationSupportsImageWithMaxCount What would be the reason why some apps show and some don't? How do I fix it?
Replies
0
Boosts
0
Views
898
Activity
Jan ’22
iOS Share Extension + NSFetchedResultsController not returning results
I am sharing my CoreData model between my iOS main app target and a new Share Extension target like this post:  This is working well for the most part except for one thing.  NSFetchedResultsController is not returning results when called from the Shared Extension. What is strange though is that if I do a plain NSFetchRequest in my Share Extension, I do get CoreData results returned that were originally saved from the main app...so I think Container setup as well as model must be being shared correctly via AppContainer. NSFetchedResultsControllerDelegate controllerDidChangeContent is never called. Any ideas or suggestions? import UIKit import MobileCoreServices class ShareViewController: UIViewController { private(set) lazy var resultsController: NSFetchedResultsController<Person> = createFetchedResultsController() override func viewDidLoad() { super.viewDidLoad() let fetchRequest = NSFetchRequest<Person>(entityName: "Person") fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] do { /// this works! let persons = try CoreDataManager.shared.managedObjectContext.fetch(fetchRequest) print("Got \(persons.count) Persons") } catch { print("Fetch failed") } activateResultsController() } func createFetchedResultsController() -> NSFetchedResultsController<Person> { CoreDataManager.shared.container.viewContext.stalenessInterval = 0 CoreDataManager.shared.container.viewContext.refreshAllObjects() CoreDataManager.shared.container.viewContext.stalenessInterval = -1 let fetchRequest = NSFetchRequest<Person>(entityName: "Person") fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] ////managedObjectContext: CoreDataManager.shared.managedObjectContext, let controller = NSFetchedResultsController( fetchRequest: fetchRequest, managedObjectContext: CoreDataManager.shared.managedObjectContext, sectionNameKeyPath: nil, cacheName: nil ) controller.delegate = self return controller } private func activateResultsController() { do { try resultsController.performFetch() } catch { fatalError("Failed to fetch entities: \(error)") } } } // MARK: - Results Controller Delegate extension ShareViewController: NSFetchedResultsControllerDelegate { func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) { guard let sections = resultsController.sections else { return } let section = sections[0] let rows = section.numberOfObjects print("rows=\(rows)") } } import UIKit import CoreData class CoreDataManager { static let shared = CoreDataManager() internal var container: NSPersistentContainer var managedObjectContext: NSManagedObjectContext { container.viewContext } init() { container = NSPersistentContainer(name: Constants.name) guard let storeDirectory = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first else { // We'll throw a fatalError() because we can't really proceed without storeDirectory fatalError(file: "Could not find .applicationSupportDirectory - exiting") } let storeURL = storeURL(for: "group.mygroup.testshareextensioncoredata", databaseName: "\(Constants.name)") let storeDescription = NSPersistentStoreDescription(url: storeURL) container.persistentStoreDescriptions = [storeDescription] container.loadPersistentStores(completionHandler: { storeDescription, error in if let error = error as NSError? { // We'll throw a fatalError() because we can't really proceed without loading the PersistentStore fatalError("loadPersistentStore failed \(error), \(error.userInfo)") } }) } // MARK: - Core Data Saving support func saveContext() { managedObjectContext.performAndWait { if managedObjectContext.hasChanges { do { try managedObjectContext.save() } catch { } } } } /// Returns a URL for the given app group and database pointing to the sqlite database. func storeURL(for appGroup: String, databaseName: String) -> URL { guard let fileContainer = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroup) else { fatalError("Shared file container could not be created.") } return fileContainer.appendingPathComponent("\(databaseName).sqlite") } } internal extension CoreDataManager { enum Constants { static let name = "ShareExtensionCoreDataTest" } }
Replies
3
Boosts
0
Views
1.9k
Activity
Jun ’22
Non existent files shown in files app
I have a files provider app that seems to be working perfectly except for one thing. If I have a directory open in the files provider app and then put the app into the backround and while in the background a file is renamed in the open directory via some other app, then when the files app comes back into the foreground it shows the file with the old name as well as the new name. I can see via logging that the FileproviderEnumerator is being closed when the app is moved to the background and then reopened when it is moved back into the foreground and I can also see that the correct file names are loaded into it when enumerating. It looks like the files app doesn't check to see if what it currently has in its cache matches what was just loaded and remove anything that is missing. To make it more confusing this only appears to be a problem on some devices and not others. It is a problem on my iPad running iPadOS 15.2.1. I have tried having the parent app, which did the file rename send a change notification but that doesn't seem to work either. If I call the following in my app: [NSFileProviderManager.defaultManager signalEnumeratorForContainerItemIdentifier:identifier completionHandler:^(NSError * _Nullable error){ if (error != nil) NSLog(@"signalEnumeratorForContainerItemIdentifier error:%@", error); else { NSLog(@"signalEnumeratorForContainerItemIdentifier OK"); } }]; I see the following message in the console log from the fileproviderd: [DEBUG] Received error NSError: Cocoa 3072 "" while sending didChangeItemID:completionHandler: on behalf of myApp[955] Do I need to explicetly tell the files app when a file has been deleted or renamed?
Replies
0
Boosts
0
Views
1k
Activity
Jan ’22
iOS Share Extension gives non existent file URL
G'day, I'm working on a share extension for our iOS app where the users are able to select multiple photos or videos and choose to share it conversations inside the app. Similar to other chat apps are doing. I ran into a problem where the file URL extracted through the inputItem's attachment are non existent for some of the files. For example share extension gives file URL such as this, file:///var/folders/4r/qlw_jjvj3w7gh5mssgzhx15w0000gp/T/com.apple.Photos/ShareKit-Exports/2918015E-B07C-4F35-9D98-86B58464DE88/B699E8DE-4965-4C0F-9D9B-4956E5E02730/IMG_1234.jpg But there is no such file in that location. Instead there is a file named IMG_1234.png (or different file extension), for certain items in user's photo library. How does this happen? Am I supposed to query the files inside the parent directory and locate truely existing file from it by ignoring the returned file name or some other way. When the same file is shared from other apps such as airdrop, mail, notes, they seem to have no problem opening up this file and the saved file (e.g. from airdrop) has identical file name and properties (IMG_1234.png) at final destination. Below is code snippet on how I process the extension context in my share extension. // I'm getting first input item here, I've checked and there are no more than 1 input item for the affected assets that are causing problem guard let itemProviders = (extensionContext?.inputItems.first as? NSExtensionItem)?.attachments else { return } var items: [Attachment] = [] // Attachment is a custom type that contains file url or image data itemProviders.forEach { itemProvider in if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeImage as String) { let desiredTypeIdentifier: String = kUTTypeImage as String itemProvider.loadItem(forTypeIdentifier: desiredTypeIdentifier, options: nil) { data, _ in if let url = data as? URL { items.append(.init(data: .file(url))) // the URL returned above is incorrect for the affected items. It's reproducible every time. } else if let image = data as? UIImage { items.append(.init(data: .memory(image))) } } } } Regards,
Replies
0
Boosts
0
Views
1.5k
Activity
Jan ’22
Mouse input completely disabled in Password AutoFill App Extension in Safari
Hi, We are receiving complaints from some users about our Password AutoFill component on macOS. The issue usually presents itself after some time, but it's pretty severe. When a user chooses our App to AutoFill their passwords, usually in Safari, we present a sheet allowing them to search from and choose a particular credential to fill. This works pretty well most of the time. However, after continued use, users report that they can no longer interact with the sheet using the mouse. Keyboard events seem to be fine, they can navigate using the up and down keys, but any clicks are just not registered. We've asked users to look in the console and let us know if they see anything strange. We've got a report back that Console is filled with: invalid display identifier <private> Also, it's speculative but all reports appear to be users using a second external display and it may possibly be related to the Mac going to sleep and the issue occurs after waking up. The solution for our users is to terminate Safari, upon restart the issue is resolved until the next time it begins, sometime later. Is there anything we can do, have you heard of an issue like this before, what could possibly block mouse events after a long period of time? Is this an App Extension issue, a Safari issue, a presenting a Sheet from an App Extension inside Safari issue? Any help appreciated.
Replies
0
Boosts
0
Views
739
Activity
Feb ’22
Web extension website permissions handling seems weak
I have a web extension that needs to operate on several websites (in fact, it opens a tab and navigates through those websites). Apple's documentation says " Safari shows a badge next to your extension’s item that indicates the user needs to interact with the extension to grant it permission." I see no such badge next to my extension. If I hover over the extension icon, then I see the message "The extension 'xxx' would like access to additional websites" (Is this the badge referred to?) This is not obvious enough to the user (it took me two days to figure out that this is why my extension wasn't working). Further, when one is in the Safari Settings "Websites" tab to give permission to the extension, they must individually change the setting for each website (from "Ask" to "Allow") -- there is no "Allow all" option. How can I affect this process to make it less of a mystery to users and as easy as possible for them to grant me access?
Replies
0
Boosts
0
Views
661
Activity
Feb ’22
Storage API gives inexplicable "Storage Quota Exceeded" error
I'm getting a "Storage Quota Exceeded" error when adding to the extension's sync storage area. getBytesInUse returns 88824, but trying to add {test: 'test'} gives the error. See attached screen shot. Safari version is 15.1, macOS version is 12.0.1. My available disk space is 523GB, so that's not the problem.
Replies
0
Boosts
0
Views
719
Activity
Feb ’22
Banner of local notification from broadcast upload extension may not work.
Hi. I implemented a broadcast upload extension and it requests local notifications. The local notification works normally on broadcastStarted(withSetupInfo:), but the Banner of the local notification does not work on processSampleBuffer(_: with:) though its Notification Center works normally. What am I missing? Here is my code snippets. container app class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. requestAuthorization() ... } private func requestAuthorization() { let center = UNUserNotificationCenter.current() center.requestAuthorization(options: [.alert]) { granted, error in if let error = error { // Handle the error here. print(error) } if granted == true { center.delegate = self center.getNotificationSettings(completionHandler: { setting in print(setting) }) } else { print("not permitted") } } } } upload extension class SampleHandler: RPBroadcastSampleHandler { override func broadcastStarted(withSetupInfo setupInfo: [String : NSObject]?) { super.broadcastStarted(withSetupInfo: setupInfo) notification(title: "Upload Extension", body: "broadcastStarted") ... } override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) { super.processSampleBuffer(sampleBuffer, with: sampleBufferType) ... if some condition { notification(title: "Upload Extension", body: "processSampleBuffer") } } private func notification(title: String, body: String) { let content = UNMutableNotificationContent() content.title = title content.body = body let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil) let notificationCenter = UNUserNotificationCenter.current() notificationCenter.add(request) { error in if error != nil { print(error) } } } }
Replies
3
Boosts
0
Views
2.6k
Activity
Jun ’23
macOS 12.2 FileProviderExtension won't be loaded
Hi, I am new to macOS development. I am trying to develop macOS FileProvider extension, and everything was fine until I updated my macOS from 11 to 12.2. After updating OS, FileProvider extension won't being loaded by NSFileProviderManager.add(domain) and its completion handler returns error - NSFileProviderDomain.Error.providerNotFound @IBAction func tapAddDomainButton(_ sender: Any) { NSFileProviderManager.add(domain) { error in print("Add domain error: \(error)") // <- Error: Optional(Error Domain=NSFileProviderErrorDomain Code=-2001 "The application cannot be used right now." UserInfo={NSLocalizedDescription=The application cannot be used right now.}) } } I've made a new boilerplate project with default macOS > App + 'File Provider Extension' in Xcode, and still got same error. Same code works on macOS 11.6.1 Weird thing is that apple sample code won't return error and still works in macOS 12.2. I can't find any difference between my code and apple sample. Apple Sample Code I uploaded my test project here. Please help Thanks in advance.
Replies
3
Boosts
0
Views
2.5k
Activity
Feb ’22
Trash character in webview's textfield
Using iOS keyboard extension, I want to move the caret to first of strings in textfield. So, I try to get the string before cursor, and move cursor. The offset is the text length, like below. The textfield's text in safari(apple.com search field) is "abcd". But, the return value is " abcd" including space character at first. So, the cursor does not move because the length(length 5) is exceeded the real text length(length 4). This is definitely appeared independently of iOS versions. guard let text = textDocumentProxy.documentContextBeforeInput else {       return     }           print("text(\(text)) = \(text.count)")           textDocumentProxy.adjustTextPosition(byCharacterOffset: -text.count)
Replies
0
Boosts
0
Views
575
Activity
Feb ’22