[iOS] [Objective-C] How to update a widget from an Objective-C app

Prepare a wrapper (swift file)

WidgetKitHelper.swift

import WidgetKit
    
    @available(iOS 14.0, *)
    @objcMembers final class WidgetKitHelper: NSObject {

          class func reloadAllWidgets(){
 
            #if arch(arm64) || arch(i386) || arch(x86_64)
            WidgetCenter.shared.reloadAllTimelines()
            #endif

          }
    }

Import swift code

#import "Product name-Swift.h"
What is a product name?
  1. Select an app from the Targets section of the Project Navigator (on the left side of Xcode)
  2. Click the Build Settings tab
  3. Search by "Product Name"

Now you can use

    if (@available(iOS 14.0, *)) {
        [WidgetKitHelper reloadAllWidgets];
    }

When updating in the background

- (void)applicationDidEnterBackground:(UIApplication *)application {
    if (@available(iOS 14.0, *)) {
        [WidgetKitHelper reloadAllWidgets];
    }
}

Reference

Recommended Posts

[iOS] [Objective-C] How to update a widget from an Objective-C app
How to deploy an app that references a local jar to heroku
[IOS] How to get data from DynamoDB
How to call Swift 5.3 code from Objective-C
How to make an app with a plugin mechanism [C # and Java]
How to get a heapdump from a Docker container
[swift5] How to transition from the app to an external site by specifying the URL
How to get an arbitrary digit from a number of 2 or more digits! !!
How to start a subscript from an arbitrary number in Ruby iterative processing
What you need to know before writing a test in an iOS app
How to run the SpringBoot app as a service
How to use an array for a TreeMap key
How to jump from Eclipse Java to a SQL file
How to push an app developed with Rails to Github
How to deploy to Heroku from a local docker image
How to update devise user information without a password
How to output standard from an array with forEach
How to play YouTube videos directly on iOS app
[Java] How to erase a specific character from a character string
Send a command to Spigot from an external process
How to get started with creating a Rails app
From building an AWS cloud environment to deploying a Spring Boot app (for beginners)
How to create an application
How to transition from the [Swift5] app to the iPhone settings screen
How to connect a container created later to an existing network
How to write a migration from Rails datetime type to date type
How to deploy a simple Java Servlet app on Heroku
[IOS] How to get the table name from AWS DynamoDB
How to create a form to select a date from the calendar
How to change a string in an array to a number in Ruby
How to leave a comment
[IOS] What you need to know before creating a widget
[Java] How to convert a character string from String type to byte type
How to store a string from ArrayList to String in Java (Personal)
How to Burning a Install Disk of Windows from Ubuntu
How to update with activerecord-import
How to specify db when creating an app with rails
How to deploy a kotlin (java) app on AWS fargate
How to make an app using Tensorflow with Android Studio
How to develop and register a Sota app in Java
[iOS] How to read Carthage
How to handle an instance
Learn how to customize the Navigation Bar from the sample app
[IOS14] How to get Data type image data directly from PHPickerViewController?
How to migrate from JUnit4 to JUnit5
How to insert a video
How to create a method
[Integration test code] How to select an element from date_select
How to run a Kotlin Coroutine sample from the command line
How to build an Apache Flink application from scratch in 5 minutes
How to open a script file from Ubuntu with VS code
How to create a web server on an EC2 instance on AWS
[Swift5] How to communicate from ViewController to Model and pass a value
How to push from Tarminal to GitHub
How to add columns to a table
[Java] How to update Java on Windows
How to make a Java container
Try to implement iOS14 Widget function
How to sign a Minecraft MOD
How to make a JDBC driver
[Java] How to create a folder