I'm trying to make a custom notification alert. I added my extension target and changed the UNNotificationExtensionCategory value to 'drawing'.
In my push notification I added a "category" : "drawing" element to the aps block. The didReceive(_:) method from that extension is never getting called though. What did I forget to do?
You seem to have done whats needed. I too had similar problem of not seeing the custom notification screen.
However, whats not mentioned in the documents of UNNotificationContentExtension is that the custom screen appears only when you do a 3D touch on the notification alert. I tried to do a 3D touch and the custom screen appeared. Please check.
First check that the extension category is set appropriately in the extension info.plist file to match what is being sent in the aps block of your push notification
Second check that the deployment target for the extension is <= to the iOS version of the device you're trying to run on.
Have u added this in your target's info.plist file instead of ACTIONABLE add drawing
I had similar issue, it was just that in the plist I made my UNNotificationExtensionCategory to be an Array and I wasn't adding them correctly.
Incorrect:
It shouldn't come next to UNNotificationExtensionCategory ie it shouldn't be a field of NSExtensionAttributes
Correct:
It should be a field of UNNotificationExtensionCategory
Apparently to learn how to use the plist you need at least 25 years of experience :)
This method is only called once you force touch into the notification.
If you are monitoring this through LLDB, it runs as a separate process. Make sure you're building your extension target in order to access these methods and the logs from LLDB.
Lastly, if you are like me, and you have discarded the storyboard, then you need to specify the principal class in your extensions Info.plist. This class must be your main view controller including the target namespace. For example, if your extension is MyNotificationExtension then you would set NSExtension > NSPrincipalClass to MyNotificationExtension.MyNotificationExtensionViewController.
Related
i'm working on developing share extension.
I add NSExtensionActivationRule in info.plist. and my app appear on activity view when it match file type.
But in some app(not for all) trying to share image (ex. google drive..) this (Copy to *) icon has already on the activity view before i start develop. so i have two my app icon on activity view/ first one i created, second already in it.
i try to make a change in plist reomve another attributes, but none of them working correctly
i want to disappear "Copy to MyApp" let me know someone knows about this.
Finally after long research and test i found solution~!!!
there is "Document types" key in info.plist in project.
My Project has been set All files supports so I delete this property .
Now that Save to MyApp icon disappear in UIActivityViewController.
I'm building a FileProvider extension for iOS 11, but we already get Document Picker View Controller extension to provide UI for iOS 10.This causes Document picker will pop out even in iOS 11.
we don't need Document Picker View Controller extension in iOS 11.
My question is how to disable Document Picker View Controller extension just for iOS 11 and later?
I finally figure this out on my own.
Apple Document says this
If you're updating an existing File Provider extension, be sure to set the NSExtensionFileProviderSupportsEnumeration key to YES in your extension's Info.plist file. If you're creating a new extension, Xcode automatically sets this key for you.
but they forget to mention that you should put NSExtensionFileProviderSupportsEnumeration key inside the NSExtension dictionary not just in that plist file.
The right plist should be looking like this
I want to create a Notification Content Extension to take advantage of the new iOS 10 rich notifications. However, in the main application we do not make use of interface builder. How can I create a content extension that does not utilize a story board?
Create the Notification Content extension target as you normally would.
Remove the storyboard file from the project
Remove the NSExtensionMainStoryboard entry from the extension's Info.plist.
Add a new entry of NSExtensionPrincipalClass to the Info.plist under NSExtension. The value should be the
namespace of your extension and the class of the main ViewController. For example, if your extension is called Pretty Notification and the class is PrettyNotificationViewController, you would enter Pretty_Notification.PrettyNotificationViewController.
Note: Your principal class must conform to UNNotificationContentExtension
I'm currently building an iOS App in Swift and I got some problems. My settings view is a tableviewcontroller. It's a grouped one. My Table View is dynamic, fonts are dynamics.
I would like to interact to the change of font size from the settings app.
If my application was already running, the font size change but the layout is just broken. (change from the smallest to the biggest font)
Image : Layout bug
If I restart my app with the new font settings, there is no problems...
Here is a XCODE project example, you'll see the bug.
Could you please help me to find a solution ? Thanks.
The UIContentSizeCategoryDidChangeNotification is what you're looking for.
Per the docs:
Posted when the user changes the preferred content size setting.
This notification is sent when the value in the
preferredContentSizeCategory property changes. The userInfo dictionary
of the notification contains the UIContentSizeCategoryNewValueKey key,
which reflects the new setting.
Example callback implementation:
func handleContentSizeCategoryDidChangeNotification(notification: NSNotification) {
self.questionLabel.font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)
}
After you change the font size try to call
self.view.setNeedsLayout()
it sets a flag in the UIView that marks it as needing layout change.
Also you can try to call
self.view.layoutIfNeeded()
Apple documentation says :
Use this method to force the layout of subviews before drawing. Using the view that receives the message as the root view, this method lays out the view subtree starting at the root.
Hope that help you
Finally, I found that it's an iOS bug. I find the same bug in the Apple Apps.
The bug happens when you set the smallest font, quit the app and set the biggest font.
Thanks for your help.
Bug Settings App
I have a basic watchkit app that loads a page based navigation of 3 interface controllers. This works well, but I'd then like to trigger an action to remove the page-control and essentially revert back to the original InterfaceController that was present when the app first loads.
// load page based control, with 3 views. this works ok
[WKInterfaceController reloadRootControllersWithNames:#[#"pageController1",#"pageController2",#"pageController3"]
contexts:#[#"data1",#"data2",#"data3"]];
// attempt to reload original interface controller, identified by storyboard id
[WKInterfaceController reloadRootControllersWithNames:#[#"myInterfaceController"] contexts:#[#{}]];
The page based navigation remove, the original navigation loads after a short spinner. However it fails to function correctly and original Actions result in this error.
Extension[6766:123665] *********** ERROR
-[SPRemoteInterface _interfaceControllerClientIDForControllerID:] clientIdentifier for interfaceControllerID:(null) not found
Is there a better way to cleanly reload the original InterfaceController?
EDIT, 2/19
It seems there are some other actions that are causing this error too. For instance, if segue to a second InterfaceController and then popController to get back, the error often appears. It is always related to a secondary call to this function.
[WKInterfaceController reloadRootControllersWithNames: contexts:]
EDIT2, 3/18
As previously mentioned, this is reproducible 100% of the time by doing the seguePush, the popController, then attempting to reloadRootControllersWithNames.
If the seguePush/popController is not done beforehand, then the reloadRootControllersWithNames will work fine.
This situation seems to be in addition to the multi->single-multi instance of this bug.
This is actually not a bug because according to Apple:
You cannot combine hierarchical and page-based interface styles. At design time, you must choose the style that best suits your app’s content and design for that style.
So unfortunately, we can't mix Hierarchical and Page-based navigation patterns within the same Watch app.
Just one of many limitations we have to deal with when developing apps for Watch
This is a bug in WatchKit in Xcode 6.2 Beta 5. Please dupe the following radar on Apple's Bug Reporting System to help raise the priority to get this fixed.
In the meantime, a workaround that I've found can be found on the dev forums. What you can do is add a dummy interface controller to any single interface controller page set so you always have two. This will fix the error until Apple get's the bug fixed (hopefully in Beta 6). Please dupe!
I was able to solve my instance of this problem by not using popController on a pushed view controller. Instead I use a reloadRootControllersWithNames in place of the popController.
How this allows both push and paging, via an example:
Push a view controller
reloadRootControllersWithNames to return to the original controller. (The transition is not quite as animated, but is sufficient)
Create page based view controller.
reloadRootControllersWithNames to return to the original controller
Repeat 1 or 3 as needed.
This eliminates the error at the cost of non-animated popControllers, and allows partial pushing and paging. It would not allow more complex push navigation though.
There may be a better method of navigating to a sub interface controller without a push call, but I'm not aware of it on the watch yet.
None or the answers above worked for me. This problem began when I changed the icon names for the app and the watch app name. I solved it like this:
1) Click on your Watch app Target > Capabilities > make sure app Group
is in ON.
2) Make sure the App Group is selected.
3) Clic on the circled arrow Refresh icon (this will apparently just
refresh this thing if you already had it)
4-Repeat steps 1-3, but for your Watch App EXTENSION target too.
5-Click on the Scheme button (on the right side of the STOP button),
and clic on Edit Schemes.
6-Click Run > Info 7-In executable select your target (Actually it
should already be selecting but opening this window seems to
refresh the option, and wipe the error)
Apparently all these things above are not updated automatically when you change the icon name (Target names) and you have to go to those menus and open them to refresh them manually. Shame on Apple perhaps?