today-extension

Send message from iOS Today Widget to app

喜你入骨 提交于 2020-01-03 11:00:10
问题 I have an alarm app, recently powered it with a today widget extension. I need to turn on and off alarm from today widget, but the code to "turn on" and "turn off" is within app, not widget. How can I send a message from today widget to main app? 回答1: You should write the setting to a shared group NSUserDefault value. See App Extension Programming Guide. If you need to immediately notify the app from the extension or vice versa, you can also use Darwin notifications, but you can never be

How to send and receive data in Today extensions

删除回忆录丶 提交于 2019-12-30 10:14:27
问题 I want to develop an app for iOS that have a Widget for notification center, but I don't know how I should send and receive data (pass data) between View Controller and And Today Extension. I tried to use structs, but it doesn't work, and also I used app groups but I don't want to use this method. let shared = NSUserDefaults(suiteName: "group.Demo.Share-Extension-Demo.mahdi") shared?.setObject("Hello", forKey: "kkk") 回答1: Apart from NSUserDefaults, you can use the NSNotificationCenter to send

Issue in Widgets in landscape mode

旧时模样 提交于 2019-12-25 04:47:10
问题 I have this irritating issue with widgets that it trims the content of my view in the landscape mode. I have put the content size statically but it doesn't work. Does Apple restrict the widget to have a specific height in landscape? Apple's interface guidelines says it's not recommended but is it doable? Edit: 回答1: There is a height limit for today widgets on iOS. The max height is (screen size) - (notification center UI height). Whatever's left after the notification center draws its UI is

How to include classes of main application in to today widgets in iOS?

不羁的心 提交于 2019-12-24 14:11:53
问题 I have got Class1.h in the main Application. And I have to use Class1.h in the Today Widget in iOS. What is the method to share the classes among the main app and widget in iOS ? 回答1: In Xcode, find Class1.m in the Project Navigator. Select it and, in the File Inspector, check the box next to your Today widget target under Target Membership. Then you should be able to import Class1.h in your Today widget code. 来源: https://stackoverflow.com/questions/34157254/how-to-include-classes-of-main

Dynamic height using Auto Layout in Today Extension

烂漫一生 提交于 2019-12-24 08:01:00
问题 EDIT: My "original" problem has been solved, it was restricted to 110 height, by "<NSAutoresizingMaskLayoutConstraint:0x6000000985b0 h=--& v=--& UIView:0x7fc83af0aeb0.height == 110 (active)>" , but that was before I read about NCWidgetDisplayMode , .Compact and .Expanded , which apparently was introduced in iOS 10. Funny thing: Looks like they had the bug when they presented the new feature in iOS 10 (https://developer.apple.com/videos/play/wwdc2016/101/?time=3221) With that implemented

EXC_BAD_ACCESS with viewWillTransitionToSize and Xcode 6.3

好久不见. 提交于 2019-12-23 12:43:06
问题 This code used to work in our today extension, but now EXC_BAD_ACCESS with using Xcode 6.3. What is the new problem? override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { coordinator.animateAlongsideTransition({ context in self.tableView.frame = CGRectMake(0, 0, size.width, size.height) }, completion: nil) } 回答1: Someone mentioned to me they think this is an Apple bug. Here's a workaround (or the solution):

Cannot retrieve data from NSUserDefaults into today extension (Swift)

孤街浪徒 提交于 2019-12-22 10:28:15
问题 I have a group of arrays that all contain a number of instances of a custom Task object that I have created. I am saving the arrays to NSUserDefaults as follows: Custom Task Object class Task:NSObject, NSCoding { var name:String var notes:String var date:NSDate var dateUse:Bool var taskCompleted:Bool init(name:String, notes:String, date:NSDate, dateUse:Bool, taskCompleted:Bool){ self.name = name self.notes = notes self.date = date self.dateUse = dateUse self.taskCompleted = taskCompleted }

UIPasteboard string returning null from Today extension

时间秒杀一切 提交于 2019-12-22 08:53:20
问题 It seems that in iOS 9/Xcode 7 beta 5, I am unable to access [[UIPasteboard generalPasteboard] string]; from my Today widget extension as every time no matter the contents, it returns (NULL). I looked through the release notes and I did not see anything regarding this. Any ideas? 回答1: It seems to be an undocumented bug with iOS 9 beta 5, in particular, the iOS runtime. Same code works with normal app on iOS 9 beta 5, and today widget in iOS 8.x devices. 回答2: My app, which is a password

Perform action in host app from Today extension(Widget) Without opening app ios

ぐ巨炮叔叔 提交于 2019-12-21 06:59:28
问题 I want to manage some action in containing app from today extension(Widget). Full description: in my containing app, some action (like play/pause audio) perform. And want to manage that action also from today extension(widget). An action continues to perform in background state as well. In today extension, the same action will perform. so for that, if in the main containing app already starts an action and send it into background state, a user can pause action from a widget. and the user also

Today Extension Crashes before launching on iOS 8.1.2

徘徊边缘 提交于 2019-12-21 03:43:07
问题 I've been making a today extension that downloads articles from a feed and display the latest ones. The whole thing worked fine on iOS 8, still worked on iOS 8.1, then came iOS 8.1.2 and we started having complaints about the today extension not working anymore. I tried debugging on iOS 8.1.2 devices, and before the extension even launch, it crashes with this error : Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key