Post

Replies

Boosts

Views

Activity

Widget refresh timeline
Hi all, I've got a pretty simple app (basically a Hootsuite like and light). I'd was hoping to create a widget that show the last post if it is today, or an view that encourages the user to create a new post. To that purpose, I create a Codable model that I store in the shared UserDefaults (suiteName) and when I do so, I call the fefrshtimeline as follows : func save() {         let encoder = JSONEncoder()         if let data = try? encoder.encode(self) {             UserDefaults.group.set(data, forKey: "lastPost")             WidgetCenter.shared.getCurrentConfigurations { (result) in                 guard case .success(let widgets) = result else { return }                 widgets.forEach { widget in                     WidgetCenter.shared.reloadTimelines(ofKind: widget.kind)                 }             }         }     } The thing is, I put a print in the timeLine and it's never called. I also tried to change the snapShot method, nothing works so far. Here are both methods from the Widget : func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {         print("🏵 getSnapshot")         if let model = ExtensionSharedModel.retrieve(), model.date.isToday {             print("🏵 add model \(model.displayName)")             completion(SimpleEntry(date: Date(), model: model))         } else {             print("🏵 no models to add...")             completion(SimpleEntry(date: Date()))         }     }     func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {         print("🏵 getTimeline")         var entries: [SimpleEntry] = []         if let model = ExtensionSharedModel.retrieve(), model.date.isToday {             print("🏵 add model \(model.displayName)")             entries = [SimpleEntry(date: Date(), model: model)]         } else {             print("🏵 no models to add...")             entries = [SimpleEntry(date: Date())]         }         let timeline = Timeline(entries: entries, policy: .atEnd)         completion(timeline)     } The widget is static configuration widget. I do enter in WidgetCenter.shared.reloadTimelines, but never in the protocol methods. Thanks for your help :-)
0
0
645
Sep ’20
Post photo to FB Page using SDK fails while it succeeds with Graph API
Hi everyone I'm struggling with this d*** FB SDK :-/ Basically, I've got an app that is supposed to post content to a FB Page. To achieve that, I login using the FB sdk. Then I request authorisations as follow LoginManager().logIn(permissions: ["pages_manage_posts", "pages_read_engagement", "pages_show_list"], viewController: controller) { result in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print("res \(result)") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;switch result { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;case .success: &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;// the pageId is in data>id &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Defaults[\.facebookSwitchOn] = true &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;GraphRequest.init(graphPath: "me/accounts").start { (connexion, result, error) in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;guard let result = result as? [String:Any], &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;let dataArray = result["data"] as? Array&lt;Any&gt;, &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;let data = dataArray.first as? [String:Any], &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;let pageId = data["id"] as? String, &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;let access = data["access_token"] as? String else { return } &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print("\(pageId)") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Defaults[\.facebookPageId] = pageId &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Defaults[\.facebookPageAccessToken] = access &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;completion(true) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;case .failed(let error): &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;completion(false) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;MessageManager.show(.basic(.custom(title: "Oups".local(), message: error.localizedDescription, buttonTitle: nil, configuration: MessageDisplayConfiguration.alert)), in: controller) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;default: () &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} I save the pageId and TokenID to be able to perform a POST request as follow GraphRequest &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;.init(graphPath: "\(pageId)/photos", //&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;parameters: ["source" : image, "caption" : text, "access_token" : token, "published" : false], &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;parameters: ["caption" : contentDescription, "url" : "https://www.cdiscount.com/pdt2/9/2/8/1/700x700/889698377928/rw/figurine-funko-pop-deluxe-game-of-thrones-daen.jpg", "access_token" : token], &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;httpMethod: .post) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;.start { (connexion, result, error) in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;completion(Result.success(true)) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} However, I get a weird error telling that publish_actions has been deprecated. I logged the request using Charles, and here it is (https:// ibb.co/89wPgKx) (remove the space after the // ) Now here is the debug from the GraphAPI explorer : curl -i -X POST \ "https://graph.facebook.com/v7.0/104226051340555/photos?caption=test%20message%20from%20Graph%20API%20for%20photo&amp;url=https%3A%2F%2Fwww.cdiscount.com%2Fpdt2%2F9%2F2%2F8%2F1%2F700x700%2F889698377928%2Frw%2Ffigurine-funko-pop-deluxe-game-of-thrones-daen.jpg&amp;access_token=&lt;access token sanitized&gt;" Basically, it is the same request excepting the fact that parameters in the explorer are URL parameters and they are encapsulated in a json. I can't understand why the graph explorer request succeeds while the SDK request fails. I'm totally stuck :-/ Thanks for your help.
0
0
755
Jun ’20
Dynamically resize Annotation's callout
Hi,I've got annotations on a MKMapView and I added a custom view inside the detailCalloutAccessoryView. This custom view performs a request and should present various amount of data depending on the request's reply. Basically, I can show 1 or 2 rows of data.Sometimes, when I touch an annotation and the result is only one row, the callout is not resized. However, if I dimiss the annotation and select it once again, it is rendered correctly.What is the "right" way to make it work? Using a intrinsicContentSize, or calling layoutIfNeeded (already tried, did not work)Thanks for your help.
1
0
1.1k
Jun ’18