today-extension

Use AppDelegate in today extension

旧街凉风 提交于 2019-12-01 20:05:46
I'm trying to build an today extension for my app. I'm using CoreData and NSFetchedResultsController and get the following error: Use of undeclared type 'AppDelegate' In this line of code: var appDel: AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate. Does someone know how to solve this error / use AppDelegate in the today extension and would like to help me? A Today Extension isn't an application, so UIApplication and AppDelegate aren't available. I'm not for sure what you are trying to do with the AppDelegate, but extensions do have a NSExtensionContext available by

Today Widget Not Launching On Device(works on Simulator)

流过昼夜 提交于 2019-12-01 17:07:18
问题 Hi I have very strange problem. My Today Widget works perfectly fine in Simulator, however when I choose to run it on real device and select 'Today' application xCode just says 'Running Today on XXX's iPhone' but on that device there is no widget. I checked in Do Not Include section and it's not there either. I've searched a lot and most of the people has three type of problems: Missing 64 bit architecture. My configuration is: Different app and extension prefix - mine are exactly the same(of

How to set response data into TodayExtenstion widget

北慕城南 提交于 2019-12-01 07:31:40
问题 Trying to access response data from service to show into TodayExtenstion Widget import Foundation struct MarketIndex:Codable { let indicesName: String let indicesValue: String let dateValue : String let indicesChangeValue : String let changePercentage : String let indexVolume: String? } struct MarketIndexCache { static let key = "MARKET_INDEX_KEY" static func save(_ value: [MarketIndex]!) { UserDefaults.standard.set(try? PropertyListEncoder().encode(value), forKey: key) } static func get() ->

How to send and receive data in Today extensions

三世轮回 提交于 2019-12-01 06:45:40
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") Apart from NSUserDefaults, you can use the NSNotificationCenter to send or receive data anywhere. You need to set the observer where you can receive the data like below: override

Layout Constraint Conflicts in Default Today Widget

混江龙づ霸主 提交于 2019-12-01 05:22:53
I have observed a very strange behavior regarding Autolayout in the Today Widget I just created for my app. Trying to get to the root of the problem I ended up creating a plain new Xcode project (single view app) and added a Today Extension as a new target - without even touching it. When I launch the Today Extension on my device (iPhone 6s) the first thing that happens is that layout constraint conflicts are thrown in the console: 2016-05-03 18:17:22.216 TodayExtension[10183:4611907] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list

Layout Constraint Conflicts in Default Today Widget

て烟熏妆下的殇ゞ 提交于 2019-12-01 02:25:04
问题 I have observed a very strange behavior regarding Autolayout in the Today Widget I just created for my app. Trying to get to the root of the problem I ended up creating a plain new Xcode project (single view app) and added a Today Extension as a new target - without even touching it. When I launch the Today Extension on my device (iPhone 6s) the first thing that happens is that layout constraint conflicts are thrown in the console: 2016-05-03 18:17:22.216 TodayExtension[10183:4611907] Unable

Open Safari from my Today Extension (widget) within my app

喜夏-厌秋 提交于 2019-12-01 02:20:33
I have a Today Extension with a text field. I want to use the contents of the text field as a URL to open a browser within my app. This is my TodayViewController.swift for my widget import UIKit import SafariServices import NotificationCenter // This extension to remove the white spaces from what pasteed extension String { func replace(string:String, replacement:String) -> String { return self.replacingOccurrences(of: string, with: replacement, options: NSString.CompareOptions.literal, range: nil) } func removeWhitespace() -> String { return self.replace(string: " ", replacement: "") } } class

Today Extension widget freezes when the main app is updated

為{幸葍}努か 提交于 2019-12-01 01:32:50
I am suffering from Today Extension freezing issue when the main app is updated. In detail, I recently found that Today Extension freezes after updating the main app from Crashlytics Beta service. After that, all of touchable things like a button does not work. I tried to reinstall the widget by setting menu supported by Today but failed. The only way to solve this symptom is rebooting iPhone device. You know, however, this is not proper solution. What makes the widget freeze after updating a main app? 来源: https://stackoverflow.com/questions/29937104/today-extension-widget-freezes-when-the

Open Safari from my Today Extension (widget) within my app

孤街醉人 提交于 2019-11-30 20:51:55
问题 I have a Today Extension with a text field. I want to use the contents of the text field as a URL to open a browser within my app. This is my TodayViewController.swift for my widget import UIKit import SafariServices import NotificationCenter // This extension to remove the white spaces from what pasteed extension String { func replace(string:String, replacement:String) -> String { return self.replacingOccurrences(of: string, with: replacement, options: NSString.CompareOptions.literal, range:

Today Extension widget freezes when the main app is updated

余生颓废 提交于 2019-11-30 20:06:40
问题 I am suffering from Today Extension freezing issue when the main app is updated. In detail, I recently found that Today Extension freezes after updating the main app from Crashlytics Beta service. After that, all of touchable things like a button does not work. I tried to reinstall the widget by setting menu supported by Today but failed. The only way to solve this symptom is rebooting iPhone device. You know, however, this is not proper solution. What makes the widget freeze after updating a