ios8-today-widget

iOS Swift Today Extension: import class from container app?

爷,独闯天下 提交于 2019-11-29 11:20:29
问题 I have an app with a Today widget. I would like to use a model class from the container app in the TodayViewController.swift . Is such a thing possible? I copied the file into the Today Extension folder and tried to import it. No dice. I can't find an answer in the documentation or online. Thanks 回答1: You need to include the file in the target membership. Select the file and then, in the right hand pane, tick the correct target. 来源: https://stackoverflow.com/questions/28301662/ios-swift-today

Finding out if the device is locked, from a Notification Widget

£可爱£侵袭症+ 提交于 2019-11-29 11:18:03
I'd like to know if the device is locked when I'm loading my Notification/Today widget, so I can show the widget appropriately. (it's financial, and we don't want to show balances on a locked phone) On devices with TouchID, I can just try to access the Keychain, and if I get errSecInteractionNotAllowed back, it's locked. All good. This doesn't work on devices without touchID (but with a PIN). I've found a few things, which recommend using [[UIApplication sharedApplication] protectedDataAvailable] However I don't have [UIApplication sharedApplication] in a widget. Any ideas where and how to do

iOS Today Extension Table View Rows only detects taps on a label

好久不见. 提交于 2019-11-29 10:47:23
I am having the weirdest of problems with a today widget on iOS. I have a simple widget with a table view like this: https://grab.edr.io/2e557aa43a34b7460b1eac44cbcaf596.png The thing is, it only responds to touches (the rows only get highlighted) when I tap one of the labels, and not the rest of the row (which is blank). This happens on both device and simulator. I am detecting touches using tableView:didSelectRowAtIndexPath:, so I am not being able to see a problem there. Here is a screenshot of my storyboard: https://grab.edr.io/c2dc09db20ded2b471dc94ea339141b8.png Any help or idea would be

Debug info when run today extension

南楼画角 提交于 2019-11-29 05:33:17
Got this debug info when debug a today extension app "host connection < NSXPCConnection: 0x170113560 > connection from pid 53 invalidated" does anyone know what this means? it shows almost every time when "widgetPerformUpdateWithCompletionHandler" called. NSXPCConnection API is used to perform interprocess connection between Xcode client and your app on iPhone. So you do not need to worry about this one. Link: https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingXPCServices.html So there may be 2 reasons that your widget is terminated. You

coredata - move to app group target

时光毁灭记忆、已成空白 提交于 2019-11-29 04:04:43
I am new to the Today extension and using an embedded framework. Our app currently uses core data backed by sqlite. If I want to share this between the app and the today extension, should I move this to a framework to be shared by both? How can I migrate our current version in the app store to be able to upgrade to a new structure? In case someone wants the solution in swift just add below function in didFinishLaunchingWithOptions. func migratePersistentStore(){ let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel) var storeOptions = [AnyHashable : Any]()

“This app contains an app extension with an illegal bundle identifier” issue

China☆狼群 提交于 2019-11-29 03:48:56
I'm a bit mixed up, since I changed the app name, Bundle Display name, and Bundle identifier name...and now my app works properly, but my today widget won't. Whenever I try to run today widget, it builds successfully, but instead of being launched, it says This app contains an app extension with an illegal bundle identifier. App extension bundle identifiers must have a prefix consisting of their containing application's bundle identifier followed by a '.'. However, I checked Info.plist and my bundle identifier is com.myname.myappname and my bundle identifier of my today widget is com.myname

Scheduling local notification from within a Today extension

£可爱£侵袭症+ 提交于 2019-11-28 21:35:43
I'm making an app that contains a Today Extension. The today extension displays a list of timers, and if the user selects one of the timers, I'd like to create and schedule a local notification for that timer. My problem is that scheduling of notifications is done with this line of code: UIApplication.sharedApplication().scheduleLocalNotification(notification) which very unfortunately relies on UIApplication.sharedApplication() that is not accessible from an extension. So my question is: How can I schedule a local notification from within a Today extension? Funnily enough, I can make a

Height of iOS8 Today Extension using Only Auto Layout Gives Broken Constraints

删除回忆录丶 提交于 2019-11-28 16:12:04
Apple documentation suggests setting the height of Today Extensions using autolayout. If a widget has additional content to display, you can rely on Auto Layout constraints to adjust the widget’s height as appropriate. If you don’t use Auto Layout, you can use the UIViewController property preferredContentSize to specify the widget’s new height. However, every example and tutorial I have seen ends up using preferredContentSize . All of my attempts to set the height via autolayout lead to warnings of broken constraints. Setting Height Via Autolayout I started with a fresh xcode template, and a

Today Extension Failed to inherit CoreMedia permissions from

∥☆過路亽.° 提交于 2019-11-28 16:10:31
问题 I am trying to add a Today Extension in Swift to my Objective-C app. I keep getting this message in my debugger log: Failed to inherit CoreMedia permissions from 3005: (null) . The number ex. 3005 is different every time. I am reading from NSUserDefaults from within the widget but I am reading/writing in the app itself. The only code in my TodayViewController is this the following: override func viewDidLoad() { super.viewDidLoad() let formatter = NSNumberFormatter() formatter.numberStyle =

NSUserDefaultsDidChangeNotification and Today Extensions

喜你入骨 提交于 2019-11-28 07:36:40
I am developing an iPhone app with a Today Extension . The app has a Model module that loads from/saves to NSUserDefaults . Since I want this information to be available to both the main app and the extension, I use an app group: let storage = NSUserDefaults(suiteName: "group.etc.etc.etc...") Both the app and the extension can access the information without any problem. The main app occasionally might create a local notification to present to the user. That notification has two actions associated with it ( UIUserNotificationAction ). One of those actions triggers some code run on the