Closed hasanmhallak closed 3 months ago
@larryaasen could you please review this suggestion and its associate PR so I can include it in my production?
@hasanmhallak Look at the latest version of this package with a latest customization options. I think it now meets your needs. If not, please open a new issue with your details.
This is not relevant any more as you can now override the Upgrader
class as below:
class AppUpgrader extends Upgrader {
@override
bool blocked() {
final installed =
int.tryParse(currentInstalledVersion?.split('.').first ?? '');
final store = int.tryParse(currentAppStoreVersion?.split('.').first ?? '');
if (installed == null || store == null) return false;
// block only if it's a major update.;
return store > installed;
}
}
So I'll close this.
@hasanmhallak how do you do if I want to show only when minor update or major? for example: 1.1.1 -> 1.1.2, don't show upgrader 1.1.4 -> 1.2.1 show upgrader 1.10.1 -> 2.0.0 sho upgrader
Introducing the ShouldBeBlocking Callback
Incorporating custom logic to determine whether an update should be enforced or not can greatly enhance the functionality of the upgrader package. The ShouldBeBlocking callback provides a valuable solution to this requirement.
Consider the following code snippet:
This simple yet powerful approach enables you to enforce updates based on predefined conditions that are less likely to change over subsequent app updates. For instance, you can enforce major releases or crucial hotfix patches, while allowing users to make their own decision regarding minor updates.
The ShouldBeBlocking callback offers several advantages over alternatives like AppCast or minAppVersion. Configuring those alternatives manually can be time-consuming and may require rewriting significant parts of the code. Moreover, AppCast setup can pose challenges, especially for beginners, due to its complexities and intricate configuration. On the other hand, relying solely on the minimum app version specified in the app store description carries risks, as it disperses the enforcement logic outside of the app itself. It's worth noting that the individuals responsible for writing app store descriptions may not be the developers themselves, introducing potential discrepancies.