Posts

Showing posts with the label swift4

Push notification is not working when app is in background (minimized) - IOS

Image
Clash Royale CLAN TAG #URR8PPP Push notification is not working when app is in background (minimized) - IOS I'm newbie to Swift, i am creating chat application, i need to send notification when app is in foreground or minimized. but i am not getting the notification when app is minimized (it works when USB is connected. func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { Messaging.messaging().appDidReceiveMessage(userInfo) let action = userInfo["action"] as! String let notification = UILocalNotification() notification.fireDate = NSDate() as Date notification.alertTitle = "test" notification.alertBody = "test" notification.alertAction = "Ok" UIApplication.shared.applicationIconBadgeNumber = 1 UIApplication.shared.scheduleLocalNotification(notification) completi...

How to change UITableView Label to mutiple color

Image
Clash Royale CLAN TAG #URR8PPP How to change UITableView Label to mutiple color How do I change the text in my UITableView to two different colors? let highest = (history[indexPath.row].highest!) //Red color let lowest = (history[indexPath.row].lowest!) //Green color cell.detailTextLabel?.text = "$(highest)/$(lowest)" return cell Thank you! use attributed text for this use two colors one for lowest and other highest – Vinodh 3 mins ago 1 Answer 1 You can prepare a custom view with two labels, one for highest, other for lowest. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your ...

FetchedResultsController Using Predicate to Exclude Results Contained in a Set

Image
Clash Royale CLAN TAG #URR8PPP FetchedResultsController Using Predicate to Exclude Results Contained in a Set I am attempting to filter the items in my FetchedResultsController to filter out a certain set of items. These are engines which have a certain letter designation in them followed by numbers. The possible rage of letters in the designation are from "A" to "O". I would like to be able to filter out engines that have the designations from "D" to "O" based on another condition. I set a constant "highPowerEngines" that is a set containing those letters. Since the designation only contains one letter, I want to exclude any designation that contains any of the letters in highPowerEngines. So far, this is my code, the predicate I am working on is contained after the FIXME: func configureFetchedResultsController() { let context = databaseController.getContext() let enginesFetchRequest = NSFetchRequest<Engine>(entityName: C...

how can I retrieve individual values from a multi value key in Swift 4/json dictionary?

Image
Clash Royale CLAN TAG #URR8PPP how can I retrieve individual values from a multi value key in Swift 4/json dictionary? There are many many examples of retrieving the value of a key, and I can do that. In this case, the key has multiple values. The key is "mining", followed by 6 values. The same key:value is repeated 30 times, with different values for the keys of course. What I can't seem to solve is how to return the values. Especially the first one, 1532825277682891390, for example, which appears to be a sub-key with key/value pairs related to that. The todo is: ["mining": { 1532825277682891390 = { command = mining; siteid = "Platform Mining"; ts = 1532825270557; user1 = 73276; value = 1; }; 1532826406100318457 = { command = mining; siteid = "Platform Mining"; ts = 1532826375712; user1 = 73276; value = 1; }; 1532827074955562013 = { command = mining; siteid = "Platform Mining...

@IBAction Function buttonPressed / tags not responsive

Image
Clash Royale CLAN TAG #URR8PPP @IBAction Function buttonPressed / tags not responsive I am trying to have a multiple choice test format — however when I try to trigger buttonPressed function using tagged buttons, my question & answer text is not updated... any advice? questionIndex = 1 @IBAction func buttonPressed(_ sender: UIButton) { if sender.tag == 1 || sender.tag == 2 || sender.tag == 3 || sender.tag == 4 && questionIndex == 1 { questionButton.text = q2 answer1.setTitle(a2a, for: .normal) answer2.setTitle(a2b, for: .normal) answer3.setTitle(a2c, for: .normal) answer4.setTitle(a2d, for: .normal) questionIndex = 2 } The first question & answers appear correctly, but never update after pressing an answer. Answer buttons have tags 1, 2, 3, & 4. UPDATE: I dragged the buttons into the function to assure connection, and now it proceeds to the next question, but then it doesn't ...

Marker move According to Route MapBox

Image
Clash Royale CLAN TAG #URR8PPP Marker move According to Route MapBox I have two annotations. There is an image on annotation. I want the image head toward route in MapBox. Here is what I have tried: func drawAnnoation (orgin :CLLocationCoordinate2D ,destination :CLLocationCoordinate2D){ if annotation == nil { annotation = CameraAnnotation(coordinate: orgin, title: "SOURCE", subtitle: "D", image:"selfImage" ) let source = orgin annotation.coordinate = source annotation.title = "ddd" map.setCenter(orgin, zoomLevel: 18, animated: false) map.addAnnotation(annotation) } else { UIView.animate(withDuration: 1.5, animations: { // Here Core Animation calls MapBox using an implicit animation. self.annotation.coordinate = orgin }) } if annotations == nil { let annotations = NoteAnnotation(coordinate: destin...