In-app update for Cocoa apps
In-app update is a separate library from Apptics and is used to show new version available alerts in Apple apps as per the configuration done in the Apptics web console. Refer to the user guide to do the configuration in the web console.
There are three different types of update alerts that you can configure, i.e. Ignorable, Remind me, and Force update. There is also an option for the non-supported OS.
Installation
Copiedsource 'https://github.com/CocoaPods/Specs.git'
target '[TARGET NAME]' do
pod 'AppticsInAppUpdate'
end
Copied#import <AppticsInAppUpdate/AppticsInAppUpdate.h>
Show the in-built pop-up
- Call the ApAppUpdateManager.checkAndShowVersionAlert method to check and show the update pop-up available.
- Pass the view controller on which you want to present the pop-up.
Copied[APAppUpdateManager checkAndShowVersionAlert:<#(UIViewController * _Nullable)#>];
CopiedAPAppUpdateManager.checkAndShowVersionAlert(<#T##UIViewController?#>)
Build custom flow
You can implement a custom update pop-up as per your app's requirements.
- The below method will return a Dictionary, allowing you to obtain data for your update pop-up UI.
- With the data obtained, you can design and implement your custom pop-up UI to display the update pop-up.
- In cases where there is no update available, the method will return null.
CopiedNSDictionary *updateInfo = [APAppUpdateManager checkForAppUpdates];
Copiedlet updateInfo = APAppUpdateManager.checkForAppUpdates()
- You can determine the response type based on the value of the category string, where 1 represents normal update data and 2 represents non-supported OS pop-up data.
- Once you get the dictionary, you can extract the key-value pairs (listed below) to create the custom UI.
Sample update dictionary
CopiedNSDictionary *updateInfo = @{
@"hasupdate" : @1,
@"latestversion" : @"2.0",
@"option" : @1,
@"popupinfo" : @{
@"description" : @"We recommend you to update to this version and enjoy our new and exciting features.",
@"ignore" : @"Ignore",
@"remindmelater" : @"Remind Me Later",
@"title" : @"New update is available!",
@"updatenow" : @"Update Now"
},
@"updatedetails" : @{
@"popuptype" : @1,
@"reminder" : @5,
@"storeurl" : @"",
@"toforce" : @0
},
@"updateid" : @782000001589015
};
Below are the keys that can be used to design custom UI:
- For custom alerts data (normal update):
- updateid: The ID corresponding to a specific update configuration.
- latestversion: The version of the app installed on the device.
- title: The title or heading for the version alert.
- description: Update features or what's new.
- remindmelater: Localized text for the `Remind Me Later` action.
- updatenow: Localized text for the `Update` action.
- ignore: Localized text for the `Ignore` action.
- The option key determines the type of UI selected for this update in the web console, i.e.:
- Flexible update flow
- Immediate update flow
- Force update flow
- reminder: The number of days before showing the pop-up again in cases where users select `remind me later` option. This can be configured from the web console.
- storeurl: A custom store URL to redirect the users when they tap on `update/download`. This can be configured from the web console.
- popuptype: The type of the alert pop-up.
- Apptics native UI alert
- Apptics custom UI alert
For non-supported OS
- title: The title of the pop-up
- description: The description of the pop-up
- continue: The button text for the pop-up
- alerttype: This determines the action as given below.
- 0: Do nothing
- 1: Install later
- 2: Freeze
- updateid: The ID corresponding to a specific update configuration.
Send stats to Apptics
Send the update status of the app to the Apptics server by using the method below. This helps in tracking user interactions related to app updates such as when an update is shown, downloaded, postponed, or ignored.
Parameters:
- updateInfo (NSdictionary): A dictionary containing details about the app update. The dictionary should include relevant information about the update such as version number, update ID, and other pertinent data.
- event (AppticsInAppUpdateStats): An enumerated value indicating the type of interaction with the app update. The possible values are:
- AppticsInAppUpdateStatsImpression: This indicates that the update notification was displayed to the user.
- AppticsInAppUpdateStatsDownload: This indicates that the user has started downloading the update.
- AppticsInAppUpdateStatsLater: This indicates that the user has chosen to be reminded about the update later.
- AppticsInAppUpdateStatsIgnore: This indicates that the user has chosen to ignore the update.
Copied[APAppUpdateManager sendStatsForUpdate:<#(nonnull NSDictionary *)#> event:<#(AppticsInAppUpdateStats)#>];
CopiedAPAppUpdateManager.sendStats(forUpdate: <#T##[AnyHashable : Any]#>, event: <#T##AppticsInAppUpdateStats#>)
Example
In the below example, updateInfo is a dictionary with details about the update and AppticsInAppUpdateStatsDownload indicates that the user has initiated downloading the update.
Note:
- Make sure that the updateInfo dictionary is not null
- Use the appropriate AppticsInAppUpdateStats value to reflect the user's interaction with the update.
CopiedAPAppUpdateManager.sendStats(forUpdate:updateInfo, event: AppticsInAppUpdateStatsDownload)