Complete guide to setting up and configuring your Flutter mobile application to work with ERP Mobile Bridge backend.
This guide provides the necessary information to set up and configure the web2app_pro Flutter application that integrates with the ERP Mobile Bridge backend to display your website in a native mobile app with push notifications, version control, and custom pages.
Run the following command to verify your Flutter installation:
flutter doctor
Ensure all required components are installed and configured.
You will receive the web2app_pro Flutter application as a source code package. Extract the files to your desired location:
cd /path/to/your/projects
unzip web2app_pro.zip
cd web2app_pro
The project's source code is located in the lib/ directory and is organized as follows:
lib/
├── config/
│ └── app_config.dart # General application configuration settings
├── models/ # Data models used throughout the app
├── screens/
│ ├── home_screen.dart # Primary dashboard or home view
│ ├── onboarding_screen.dart # Initial setup/welcome screens for new users
│ └── page_viewer_screen.dart # Screen for viewing specific pages or content
├── services/
│ ├── api_service.dart # Handles API requests and responses
│ ├── fcm_service.dart # Manages Firebase Cloud Messaging (Push Notifications)
│ └── settings_service.dart # Manages app settings and local storage
├── widgets/ # Reusable UI components
├── firebase_options.dart # Generated Firebase configuration file
└── main.dart # Entry point of the application
The application relies on several key packages (defined in pubspec.yaml):
| Category | Package | Purpose |
|---|---|---|
| WebView | webview_flutterwebview_flutter_android |
For embedding web content |
| Firebase | firebase_corefirebase_messaging |
Backend integration and push notifications |
| Networking | http |
Making HTTP requests |
| Local Storage | shared_preferences |
Saving simple data locally |
| Permissions | permission_handler |
Managing app permissions |
| Notifications | flutter_local_notifications |
Displaying local notifications |
| Connectivity | connectivity_plus |
Checking network connectivity |
| Device Info | package_info_plusdevice_info_plus |
Accessing device and package information |
After extracting the source code, install all required packages by running:
flutter pub get
pubspec.yaml. This command will
download and install them automatically.
The easiest way to configure Firebase is using the FlutterFire CLI. This will automatically generate the
firebase_options.dart file.
firebase_options.dart is present in lib/
If the file is not present, configure it using the FlutterFire CLI:
flutterfire configure
This command will:
firebase_options.dart automaticallynpm install -g firebase-tools
If you prefer manual setup:
google-services.jsonandroid/app/ directoryGoogleService-Info.plistios/Runner.xcworkspace in XcodeGoogleService-Info.plist into Runner folderThe lib/services/api_service.dart file handles all API requests to the ERP Mobile Bridge
backend.
You need to update the base URL to point to your backend server.
Open lib/config/app_config.dart and configure both the API base URL and your app key:
class AppConfig {
// TODO: Replace with actual base URL in production
static const String apiBaseUrl = 'https://web2app.lpkerp.com/api/app';
static const String appKey = 'e1661f9e94f9281a5eefcc91cdf779b22399ef87e55c57741d01a7d808796d3e';
}
apiBaseUrl with your backend server URL and
appKey
with the unique API key from your Business App in the admin panel.
All API requests require authentication using an API Key. Each business app has a unique
app_key that must be included in API requests.
Include the API key in your HTTP requests. There are two common methods:
// Example API request with app_key as query parameter
final response = await http.get(
Uri.parse('$apiBaseUrl/app-settings?app_key=YOUR_APP_KEY_HERE'),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
);
// Example API request with app_key in header
final response = await http.get(
Uri.parse('$apiBaseUrl/app-settings'),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-App-Key': 'YOUR_APP_KEY_HERE',
},
);
| Endpoint | Method | Description | Requires API Key |
|---|---|---|---|
/api/app-settings |
GET | Fetch app configuration and settings | Yes |
/api/onboarding |
GET | Get onboarding screens | Yes |
/api/pages |
GET | Fetch custom pages | Yes |
/api/version-check |
GET | Check for app updates | Yes |
/api/register-device |
POST | Register FCM token for push notifications | Yes |
import 'package:http/http.dart' as http;
import 'dart:convert';
import '../config/app_config.dart';
class ApiService {
Future<Map<String, dynamic>> fetchAppSettings() async {
try {
final response = await http.get(
Uri.parse('${AppConfig.apiBaseUrl}/app-settings?app_key=${AppConfig.appKey}'),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
);
if (response.statusCode == 200) {
final data = json.decode(response.body);
return data['data'];
} else {
throw Exception('Failed to load app settings');
}
} catch (e) {
print('Error fetching app settings: $e');
rethrow;
}
}
}
The WebView functionality is already implemented in lib/screens/home_screen.dart. This screen
loads your website URL and provides features like:
Push notification functionality is already implemented in lib/services/fcm_service.dart. This
service handles:
flutter build apk --debug
flutter build apk --release
flutter build appbundle --release
flutter build ios --debug
flutter build ios --release
Create a keystore:
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
Create android/key.properties:
storePassword=your_password
keyPassword=your_password
keyAlias=upload
storeFile=/path/to/upload-keystore.jks
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
Update version in pubspec.yaml:
version: 1.0.0+1 # version_name+version_code
The version code should match what you configure in the ERP Mobile Bridge admin panel for version checking.
After completing the setup steps above, run the application on a connected device or emulator:
flutter run
Check that the following are working correctly: