GRVAppUpdateIntervalDelegate
You can customize intervals to control how often the SDK checks for new mini program versions for asynchronous and synchronous updates. Intervals are measured from the mini program's first launch or most recent update.
The following table shows how custom intervals apply to different update modes:
Update mode | Affected by async update interval | Affected by sync update interval |
Default mode (uses both async and sync updates) | Yes | Yes |
Async mode | Yes | No |
Sync mode (checks for updates every time the mini program opens) | No | No |
For more information about mini program updates, refer to Mini program update mechanism.
To customize update intervals, implement the GRVAppUpdateIntervalDelegate
protocol. This topic provides implementation steps and protocol specifications.
Default experience
If you do not customize the update intervals, the SDK uses the following defaults:
- Asynchronous updates: every one hour
- Synchronous updates: every 10 days
Before you begin
Ensure that the integrated iOS IAPMiniProgram SDK is version 2.65.3 or later. For more information, see SDK release notes.
Procedure
To customize the mini program update intervals, take the following two steps:
Step 1: Implement the GRVAppUpdateIntervalDelegate
protocol
Create a class that implements the GRVAppUpdateIntervalDelegate
protocol. Within the class, implement the following methods as needed:
syncUpdateIntervalForApp
: Customizes the interval for checking for synchronous updates.asyncUpdateIntervalForApp
: Customizes the interval for checking for asynchronous updates.
For more information about the protocol and methods, refer to GRVAppUpdateIntervalDelegate
. Refer to the following code for a sample implementation:
class DemoAppUpdateIntervalDelegate: NSObject, GRVAppUpdateIntervalDelegate {
func syncUpdateIntervalForApp() -> TimeInterval {
// Return the interval for synchronous updates
}
func asyncUpdateIntervalForApp() -> TimeInterval {
// Return the interval for asynchronous updates
}
}
Step 2: Configure appUpdateIntervalDelegate
After initializing the SDK, create an instance of GRVExtensionDelegate
and assign the implementation (for example, DemoAppUpdateIntervalDelegate
in the sample) to the appUpdateIntervalDelegate
property. Refer to the following code for a sample configuration:
let extensionDelegate = GRVExtensionDelegate()
extensionDelegate.appUpdateIntervalDelegate = DemoAppUpdateIntervalDelegate()
Structures
GRVAppUpdateIntervalDelegate
protocol
The GRVAppUpdateIntervalDelegate
protocol defines methods for the super app to customize intervals for synchronous and asynchronous mini program updates. Refer to the following code for the protocol definition:
@protocol GRVAppUpdateIntervalDelegate <NSObject>
@optional
/// The interval for synchronous updates
- (NSTimeInterval)syncUpdateIntervalForApp;
/// The interval for asynchronous updates
- (NSTimeInterval)asyncUpdateIntervalForApp;
@end
Based on the definition, this protocol provides the following methods:
Method | Description |
syncUpdateIntervalForApp | Called by the SDK to obtain the custom interval for synchronous updates. The super app needs to return the interval in seconds as an If this method is not implemented, the SDK defaults to 10 days. |
asyncUpdateIntervalForApp | Called by the SDK to obtain the custom interval for asynchronous updates. The super app needs to return the interval in seconds as an If this method is not implemented, the SDK defaults to one hour. |