Skip to content

Commit a921a4e

Browse files
Add support for update message localization
1 parent a18e2ff commit a921a4e

File tree

8 files changed

+226
-22
lines changed

8 files changed

+226
-22
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@
2727
.dart_tool/
2828
.packages
2929
build/
30+
.flutter-plugins
31+
.flutter-plugins-dependencies

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class MyApp extends StatelessWidget {
4343
appVersion: '1.0.0', // Your app version
4444
platform: 'android', // App Platform, android or ios
4545
environment: 'production', // Environment in which app is running, production, staging or development etc.
46+
appLanguage: 'en' // App language ex: en, es etc. Optional.
4647
);
4748
4849
return MaterialApp(
@@ -52,7 +53,7 @@ class MyApp extends StatelessWidget {
5253
title: Text('App Upgrade Flutter Example'),
5354
),
5455
body: AppUpgradeAlert(
55-
xApiKey: 'MmQwMDU3YWEtNmEzOC00NjQ4LThlYWItNWQ4YTI3YzZdfjdkfdkfdg5', // Your x-api-key
56+
xApiKey: 'ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5', // Your x-api-key
5657
appInfo: appInfo,
5758
child: Center(child: Text('Hello World!')),
5859
)
@@ -91,6 +92,7 @@ class MyApp extends StatelessWidget {
9192
appVersion: '1.0.0',
9293
platform: 'android',
9394
environment: 'production',
95+
appLanguage: 'en' // App language ex: en, es etc. Optional.
9496
);
9597
9698
DialogConfig dialogConfig = DialogConfig(
@@ -158,6 +160,7 @@ class MyApp extends StatelessWidget {
158160
appVersion: '1.0.0', // Your app version
159161
platform: 'android', // App Platform, android or ios
160162
environment: 'production', // Environment in which app is running, production, staging or development etc.
163+
appLanguage: 'en' // App language ex: en, es etc. Optional.
161164
);
162165
163166
return MaterialApp(

example/README.md

Lines changed: 198 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,204 @@
1-
# example
1+
# App Upgrade: Flutter SDK
22

3-
A new Flutter project.
3+
Flutter SDK for [App Upgrade](https://appupgrade.dev)
44

5-
## Getting Started
5+
App Upgrade is a service let your users know when to upgrade your apps or force them to upgrade the app.
66

7-
This project is a starting point for a Flutter application.
7+
[![Twitter](https://img.shields.io/twitter/follow/app_upgrade?style=social)](https://twitter.com/app_upgrade)
8+
[![YouTube](https://img.shields.io/youtube/channel/subscribers/UC0ZVJPYHFVuMwEsro4VZKXw?style=social)](https://www.youtube.com/channel/UC0ZVJPYHFVuMwEsro4VZKXw)
89

9-
A few resources to get you started if this is your first Flutter project:
10+
Many times we need to force upgrade mobile apps on users' mobile. Having faced this issue multiple times decided to find a better way to tackle this problem. After doing some research on how people are doing this there are so many custom solutions or checking with the play store or AppStore API if there is a new version available. Although this works if we just want to nudge users that there is a new version available. It doesn't solve the problem where we want to make a decision.. whether it's a soft graceful update or we want to force update. So here is this product that will make developers' life easy. We can set custom messages.. see the versions in beautify dashboard, and many exciting features in the roadmap ahead.
1011

11-
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12-
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
12+
## Installation
13+
With flutter
14+
```
15+
flutter pub add app_upgrade_flutter_sdk
16+
```
1317

14-
For help getting started with Flutter development, view the
15-
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16-
samples, guidance on mobile development, and a full API reference.
18+
Import the package
19+
```
20+
import 'package:app_upgrade_flutter_sdk/app_upgrade_flutter_sdk.dart';
21+
```
22+
23+
## How to use it.
24+
1. Register on App Upgrade and follow the instructions to create project and get the x-api-key.
25+
26+
2. Wrap the body widget with the `AppUpgradeAlert` widget, provide x-api-key, appInfo of your app and rest will be handled.
27+
```dart
28+
import 'package:flutter/material.dart';
29+
import 'package:upgrader/upgrader.dart';
30+
31+
void main() => runApp(MyApp());
32+
33+
class MyApp extends StatelessWidget {
34+
MyApp({
35+
Key key,
36+
}) : super(key: key);
37+
38+
@override
39+
Widget build(BuildContext context) {
40+
41+
AppInfo appInfo = AppInfo(
42+
appName: 'Wallpaper app', // Your app name
43+
appVersion: '1.0.0', // Your app version
44+
platform: 'android', // App Platform, android or ios
45+
environment: 'production', // Environment in which app is running, production, staging or development etc.
46+
appLanguage: 'en' // App language ex: en, es etc. Optional.
47+
);
48+
49+
return MaterialApp(
50+
title: 'App Upgrade Flutter Example',
51+
home: Scaffold(
52+
appBar: AppBar(
53+
title: Text('App Upgrade Flutter Example'),
54+
),
55+
body: AppUpgradeAlert(
56+
xApiKey: 'ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5', // Your x-api-key
57+
appInfo: appInfo,
58+
child: Center(child: Text('Hello World!')),
59+
)
60+
),
61+
);
62+
}
63+
}
64+
```
65+
66+
Optionally you can also provide dialog cofiguration such as dialogStyle (material or cupertino). Full details is below.
67+
68+
```
69+
dialogStyle: DialogStyle.material, // cupertino or material, default is material
70+
title: 'App update required!', // Title that will be shown in the Diaglog. Default is "App Update Required!"
71+
updateButtonTitle: 'Update Now', // Update button title. Default is "Update"
72+
laterButtonTitle: 'Later' // Later button title. Default is "Later"
73+
```
74+
75+
Example with Dialog Config:
76+
```dart
77+
import 'package:flutter/material.dart';
78+
import 'package:upgrader/upgrader.dart';
79+
80+
void main() => runApp(MyApp());
81+
82+
class MyApp extends StatelessWidget {
83+
MyApp({
84+
Key key,
85+
}) : super(key: key);
86+
87+
@override
88+
Widget build(BuildContext context) {
89+
90+
AppInfo appInfo = AppInfo(
91+
appName: 'Wallpaper app',
92+
appVersion: '1.0.0',
93+
platform: 'android',
94+
environment: 'production',
95+
appLanguage: 'en' // App language ex: en, es etc. Optional.
96+
);
97+
98+
DialogConfig dialogConfig = DialogConfig(
99+
dialogStyle: DialogStyle.material,
100+
title: 'App update required!',
101+
updateButtonTitle: 'Update Now',
102+
laterButtonTitle: 'Later'
103+
);
104+
105+
return MaterialApp(
106+
title: 'App Upgrade Flutter Example',
107+
home: Scaffold(
108+
appBar: AppBar(
109+
title: Text('App Upgrade Flutter Example'),
110+
),
111+
body: AppUpgradeAlert(
112+
xApiKey: 'MmQwMDU3YWEtNmEzOC00NjQ4LThlYWItNWQ4YTI3YzZdfjdkfdkfdg5',
113+
appInfo: appInfo,
114+
dialogConfig: dialogConfig,
115+
child: Center(child: Text('Hello World!')),
116+
)
117+
),
118+
);
119+
}
120+
}
121+
```
122+
123+
### Note:
124+
1. For opening the app store/playstore the app should be live.
125+
2. It might not be able to open the app store/playstore in simulator. You can try it in physical device.
126+
3. You can find a sample app from here [app_upgrade_flutter_demo_app](https://github.com/appupgrade-dev/app_upgrade_flutter_demo_app)
127+
4. Read detailed blog on how to integrate from here [How to upgrade/force upgrade Flutter app](https://appupgrade.dev/blog/how-to-force-upgrade-flutter-app)
128+
129+
## Screenshot of alert - material
130+
131+
![image](https://raw.githubusercontent.com/appupgrade-dev/app-upgrade-assets/main/images/forceupgrade_flutter_material.png)
132+
133+
## Screenshot of Cupertino alert
134+
135+
![image](https://raw.githubusercontent.com/appupgrade-dev/app-upgrade-assets/main/images/forceupgrade_flutter_cupertino.png)
136+
137+
## Force upgrade screenshot Example
138+
Only update button is enable. User cannot skip it.
139+
140+
![image](https://raw.githubusercontent.com/appupgrade-dev/app-upgrade-assets/main/images/forceupgrade_flutter_.png)
141+
142+
### Debugging
143+
You can provide debug true to enable debug logs
144+
```dart
145+
import 'package:flutter/material.dart';
146+
import 'package:upgrader/upgrader.dart';
147+
148+
void main() => runApp(MyApp());
149+
150+
class MyApp extends StatelessWidget {
151+
MyApp({
152+
Key key,
153+
}) : super(key: key);
154+
155+
@override
156+
Widget build(BuildContext context) {
157+
158+
AppInfo appInfo = AppInfo(
159+
appName: 'Wallpaper app', // Your app name
160+
appVersion: '1.0.0', // Your app version
161+
platform: 'android', // App Platform, android or ios
162+
environment: 'production', // Environment in which app is running, production, staging or development etc.
163+
appLanguage: 'en' // App language ex: en, es etc. Optional.
164+
);
165+
166+
return MaterialApp(
167+
title: 'App Upgrade Flutter Example',
168+
home: Scaffold(
169+
appBar: AppBar(
170+
title: Text('App Upgrade Flutter Example'),
171+
),
172+
body: AppUpgradeAlert(
173+
xApiKey: 'MmQwMDU3YWEtNmEzOC00NjQ4LThlYWItNWQ4YTI3YzZdfjdkfdkfdg5', // Your x-api-key
174+
appInfo: appInfo,
175+
debug: true, // You can specify debug true to print debug logs
176+
child: Center(child: Text('Hello World!')),
177+
)
178+
),
179+
);
180+
}
181+
}
182+
```
183+
184+
## App Upgrade Docs
185+
For more information visit [App Upgrade](https://appupgrade.dev)
186+
187+
### Changelog
188+
189+
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
190+
191+
### Contributing
192+
193+
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE OF CONDUCT](CODE_OF_CONDUCT.md) for details.
194+
195+
### License
196+
197+
The MIT License (MIT). Please see [License File](LICENSE) for more information.
198+
199+
## Need help?
200+
201+
If you're looking for help, try our [Documentation](https://appupgrade.dev/docs/) or our [FAQ](https://appupgrade.dev/docs/app-upgrade-faq).
202+
If you need support please write to us at [email protected]
203+
204+
### Happy Coding!!!

example/lib/main.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class _MyHomePageState extends State<MyHomePage> {
5858
appVersion: '1.0.0',
5959
platform: 'android',
6060
environment: 'production',
61+
appLanguage: 'es'
6162
);
6263

6364
// This is Optional.
@@ -73,7 +74,7 @@ class _MyHomePageState extends State<MyHomePage> {
7374
title: Text(widget.title),
7475
),
7576
body: AppUpgradeAlert(
76-
xApiKey: 'MDNmNmZkNDEtNmNkMi00NzY3LThjOWEtYWYxMGFjZWQ0ZjI2',
77+
xApiKey: 'ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5',
7778
appInfo: appInfo,
7879
dialogConfig: dialogConfig,
7980
debug: true,

example/pubspec.lock

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
path: ".."
88
relative: true
99
source: path
10-
version: "1.0.2"
10+
version: "1.0.4"
1111
async:
1212
dependency: transitive
1313
description:
@@ -49,7 +49,7 @@ packages:
4949
name: collection
5050
url: "https://pub.dartlang.org"
5151
source: hosted
52-
version: "1.15.0"
52+
version: "1.16.0"
5353
cupertino_icons:
5454
dependency: "direct main"
5555
description:
@@ -63,7 +63,7 @@ packages:
6363
name: fake_async
6464
url: "https://pub.dartlang.org"
6565
source: hosted
66-
version: "1.2.0"
66+
version: "1.3.0"
6767
flutter:
6868
dependency: "direct main"
6969
description: flutter
@@ -109,6 +109,13 @@ packages:
109109
url: "https://pub.dartlang.org"
110110
source: hosted
111111
version: "0.12.11"
112+
material_color_utilities:
113+
dependency: transitive
114+
description:
115+
name: material_color_utilities
116+
url: "https://pub.dartlang.org"
117+
source: hosted
118+
version: "0.1.4"
112119
meta:
113120
dependency: transitive
114121
description:
@@ -122,7 +129,7 @@ packages:
122129
name: path
123130
url: "https://pub.dartlang.org"
124131
source: hosted
125-
version: "1.8.0"
132+
version: "1.8.1"
126133
sky_engine:
127134
dependency: transitive
128135
description: flutter
@@ -134,7 +141,7 @@ packages:
134141
name: source_span
135142
url: "https://pub.dartlang.org"
136143
source: hosted
137-
version: "1.8.1"
144+
version: "1.8.2"
138145
stack_trace:
139146
dependency: transitive
140147
description:
@@ -176,7 +183,7 @@ packages:
176183
name: test_api
177184
url: "https://pub.dartlang.org"
178185
source: hosted
179-
version: "0.4.3"
186+
version: "0.4.9"
180187
typed_data:
181188
dependency: transitive
182189
description:
@@ -190,7 +197,7 @@ packages:
190197
name: vector_math
191198
url: "https://pub.dartlang.org"
192199
source: hosted
193-
version: "2.1.1"
200+
version: "2.1.2"
194201
sdks:
195-
dart: ">=2.14.0 <3.0.0"
202+
dart: ">=2.17.0-0 <3.0.0"
196203
flutter: ">=1.17.0"

lib/src/app_info.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ class AppInfo {
33
final String appVersion;
44
final String platform;
55
final String environment;
6+
String? appLanguage;
67

78
AppInfo({
89
required this.appName,
910
required this.appVersion,
1011
required this.platform,
1112
required this.environment,
13+
this.appLanguage,
1214
});
1315
}

lib/src/app_upgrade_api.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ class AppUpgradeApi {
1616
var appVersion = params.appVersion;
1717
var platform = params.platform;
1818
var environment = params.environment;
19+
var appLanguage = params.appLanguage;
1920

2021
final response = await client!.get(
2122
Uri.parse(
22-
'$appUpgradeBaseURL/api/v1/versions/check?app_name=$appName&app_version=$appVersion&platform=$platform&environment=$environment'),
23+
'$appUpgradeBaseURL/api/v1/versions/check?app_name=$appName&app_version=$appVersion&platform=$platform&environment=$environment&app_language=$appLanguage'),
2324
headers: {
2425
"Content-Type": "application/json; charset=utf-8",
2526
"x-api-key": xApiKey,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: app_upgrade_flutter_sdk
22
description: The official Flutter SDK for App Upgrade. The SDK integrates with the App Upgrade version check API.
3-
version: 1.0.3
3+
version: 1.0.4
44
homepage: https://github.com/appupgrade-dev/app_upgrade_flutter_sdk
55

66
environment:

0 commit comments

Comments
 (0)