Post

Replies

Boosts

Views

Activity

Request Notification Service Entitlement to filter remote notifications IOS
I have a sample app to test push notifications. The app has a Notification Service Extension to intercept remote notifications, update/enhance the content and then display it to user. But there are some scenarios where the app shouldn't end up displaying a notification to user... Like, due to slow internet, the time taken to download media content (like images) exceeds the 30 sec time limit. There are more app specific scenarios. Basically, every push received from APNS need not be shown to user. Notification Service Extension did not have this power to suppress remote notifications. In the end, it will always display a notification to user. From iOS 13.3 onwards, Notification Service Extension has the ability to filter out these remote notifications. The first step is (quoting form the documentation), This entitlement allows a notification service extension to receive remote notifications without displaying the notification to the user. To apply for this entitlement, see Request Notification Service Entitlement. When I click on the hyperlink (you need to be an account holder to view that page), Apple asks for some info like 'App Store URL', 'When extension runs, what system and network resources does it need?' and so on. I only have a sample app to help understand the aspects of notifications. I don't have any full-fledged app in AppStore... yet... and I have no clue what all my full-fledged app will be doing in the extension (since I'm just in learning stage). I only have a sample app, where I log and perform some basic string operations when my extension is invoked. Due to this, I'm unable to see the extension filtering out notifications. How does anyone test this feature? Has anyone tried it? Really appreciate any guidance. I'm not sure how to proceed..
0
0
1.6k
May ’23
'Import-path' in Import declaration's documentation
According to swift documentation, the following describes the various forms of the Import declaration. Grammar of an import declaration import-declaration → attributes? import import-kind? import-path import-kind → typealias | struct | class | enum | protocol | let | var | func import-path → identifier | identifier . import-path Questions: Attributes and import-kind are optional. import-kind refers to the type of the import (class, struct, enum etc etc).... defined in the second line. Does attributes refers to @available which can used to add an import for a specific platform version? In the 3rd line, I understand that identifier here refers to the names of modules, classes, funcs etc., but what does import-path mean? Can I give the actual path in disk? What all comes under this? I couldn't understand from this documentation.
0
0
631
Aug ’23
No response from AppleDTS
I've reached out to AppleDTS for code-level support on Dec 19th 2023. It's been 3 weeks now (Jan 11, 2024). I sent a follow-up 3 days ago, but no response yet. Their response time is supposed to be within 3 business days.. experiencing this level of delay in a paid support is disappointing. I'm not raising a new TSI but resuming an old one after almost 8 months because it is a continuation of the same problem. Delayed response from my side is a problem? I hope not (I didn't find any restrictions in the documentation). What should I do in this situation?
0
0
637
Jan ’24
WatchOS app launched by tapping an associated file
In iPhone, if you open Files app and tap on an associated file type, its corresponding app is launched. I have implemented this functionality in my iOS SwiftUI app - associated a file type - .csk, with my iOS app and handled its launch using the onOpenURL(perform:) modifier. WindowGroup { FileContentView() .onOpenURL(perform: { (fileUrl: URL) in Log(String(format: "File Url = %@", fileUrl.absoluteString)) // Update UI with the content of the file }) } I want to achieve the same for my watchOS app. I noticed that the UTExportedTypesDeclaration key, which is used to declare the file types created and owned by the app, is not available for watchOS. But the CFBundleDocumentTypes key, which is used to associate a file type with the app is available. So, I expect my app to respond to taps on those associated file types, but I've run into a snag. There is no Files app in AppleWatch nor is there a way to view my iCloud storage. I have my .csk file (which is associated with the watchOS app) in iCloud. So, how can I test this launch? How can an AppleWatch user tap a file and view it in his app? It should be possible to handle file launches since CFBundleDocumentTypes is available for watchOS.
0
0
631
Mar ’24
IOS SceneDelegate not invoked when extended in a different target
I have an iOS project with the following targets: SwiftExtensions (AppTarget) -> depends on Experience Experience (StaticLibrary) -> depends on Lifecycle Lifecycle (StaticLibrary) I have defined the SceneDelegate in Lifecycle library: public class SceneDelegate: UIResponder, UIWindowSceneDelegate { // scene(_:willConnectTo:options:) is implemented in Experience // scene(_:openURLContexts:) is implemented in Experience // Other methods such as sceneWillEnterForeground(_:), sceneDidBecomeActive(_:) etc. } As shown above, scene(_:willConnectTo:options:) and scene(_:openURLContexts:) are not defined here. In the Experience library, SceneDelegate is extended: extension SceneDelegate { func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { NSLog("[Experience]: SceneDelegate.scene(_:willConnectTo:options:)") if (connectionOptions.urlContexts.isEmpty) { NSLog("[Experience]: Not launched using file!") } else { NSLog("[Experience]: Launched using file!") let urlContexts: Set<UIOpenURLContext> = connectionOptions.urlContexts for (index, urlContext) in urlContexts.enumerated() { NSLog(String(format: "[Experience]: url[%d] = %@ ", index, urlContext.url.path())) } } } func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { NSLog("[Experience]: SceneDelegate.scene(_:openURLContexts:)") for (index, urlContext) in URLContexts.enumerated() { NSLog(String(format: "[Experience]: url[%d] = %@ ", index, urlContext.url.path())) } } } Now, when I tap the app icon, scene(_:willConnectTo:options:) is not invoked. When I tap an associated file type, scene(_:willConnectTo:options:) is not invoked, again. If app is running in background, and I foreground the app by tapping an associated file type, scene(_:openURLContexts:) is not invoked. Basically, when I define these two methods outside the target, despite with public access modifier, iOS doesn't invoke my delegate methods defined in the other library. My understanding was, Extensions can be used to break up the class. What is missing here?
0
0
835
Mar ’24
Deep links in AppleWatch
This page describes the procedure to create deep links in iOS. I was able to launch an IOS Companion app (name of the app in my case) using its deep link. But the same is not working in AppleWatch. This is my plist to register a custom scheme - Companion: <?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>CFBundleURLTypes</key> <array> <dict> <!-- <key>CFBundleTypeRole</key> <string>Viewer</string> --> <key>CFBundleURLName</key> <string><some unique ID></string> <key>CFBundleURLSchemes</key> <array> <string>Companion</string> </array> </dict> </array> </dict> </plist> I have implemented onOpenURL(perform:) to handle app launches using a deep link (url). var body: some Scene { WindowGroup { ContentView() .onOpenURL(perform: { (link: URL) in Log(String(format: "Link = %@", link.absoluteString)) // Use then deep link }) } } In iOS, I tested deep links in two ways: Wrote the full deep link in Notes app and tapped it. Created another app called AppLauncher with a Button saying 'Launch using Deep link'.... which when clicked opens the deep link using open(_:options:completionHandler:). Both the approaches work in iOS, but in watchOS, I can only try 2 because Notes app is not available for AppleWatch. So, I created another watchOS app called AppLauncher, which displays a SwiftUI Button saying 'Launch using Deep link', which when tapped, tries to open the link using openSystemURL(_:). But as mentioned in the documentation (linked earlier), Opens the specified system URL. this API only works for links associated with System apps i.e., Apple's call and message apps. So, how else can I use deep link to launch another app? I believe it's possible to launch an app using its deep link because the info.plist keys required to define a deep link scheme association (CFBundleURLTypes, CFBundleURLSchemes etc) is valid for watchOS too.
0
0
1.1k
Mar ’24