Build the sample Flutter app
Overview
You can use the sample app provided with our Flutter SDK to customize and test your mobile app messages with minimal effort.
Note:
The following instructions show building the sample app using VSCode. You will need to make a few changes in Xcode for iOS.
Before you begin
- Download the Acoustic Flutter plug-in.
- Install VSCode and the flutter extension. The Flutter extension package includes Dart by default.
- The Acoustic Flutter SDK supports Flutter SDK version >=2.12.0 <3.0.0. Verify the correct Flutter SDK is installed when setting up the VSCode environment.
Prepare the project
- From VSCode, open the Acoustic Flutter SDK folder by opening the project from the root of the unzipped Flutter SDK.
- You will see the following notification message: "Some packages are missing or out of date, would you like to get them now?".
- Click Get packages.
If you do not see the Get Packages prompt:
- Open the terminal in VSCode.
- Type cd applications/sample to navigate from the root directory of this project to the sample app directory.
- Then run the
flutter pub get
command.
You will also need to add the packages for each of the plug-ins.
- To update all the plug-in files, navigate to pubspec.yaml file inside one of the plug-in folders from the root directory of the SDK folder.
cd plugins/**insert your plugin folder name here**
For example, from the root directory of the SDK folder, navigate to the flutter_acoustic_mobile_push plug-in folder, cd plugins/flutter_acoustic_mobile_push
. You can find the pubspec.yaml
file for this plug-in within this folder.
2. Open the pubspec.yaml file and save it. Saving the file will initiate the Get packages prompt.
3. Click Get packages to update packages across the entire project.
4. If some packages fail to update, you will need to navigate into the pubspec.yaml file of that specific plug-in folder and save the file to re-initiate the prompt for that file.
Set up your Android app
- Go to the applications/sample/android/app/src/main/assets/MceConfig.json file and set the SDK properties. For more information, see Configuration (MceConfig.json).
- Using the terminal in VSCode, from the SDK directory of the repo folder, change the directory to
cd applications/sample
. - Run the
flutter clean
command. - Delete the pubspec.lock file in the sample app directory.
- Run the
flutter pub get
command. A new pubspec.lock file is generated. - Copy your google-services.json file and add it to the applications/sample/android/app/ directory.
- Navigate to applications/sample/android/app/build.gradle.
- Find the
defaultConfig
section in the build.gradle file and replace theapplicationId
valuecom.example.ca_mce_flutter_sdk
withyour package_name
from the google-services.json file. - Make sure an emulator/device is connected to VSCode.
- Build the project from applications/sample/lib/main.dart file. Right-click on the main.dart file and click Start Debugging.
Set up your iOS app
- Go to the applications/sample/ios/Runner/MceConfig.json file and set the SDK properties. For more information, see Configuration (MceConfig.json).
Note:
An AppKey is required to run the iOS version of this app on an initial installation.
Note:
Configure the SDK using the Swift application delegates to avoid the black screen when starting the app. For example, your value for the
appDelegateClass
for the sample app would be"Runner.AppDelegate"
.
- Within the Runner target in Xcode, verify that Profile for the Build Active Architectures Only section in the Xcode > Build Settings tab is set to
No
. If not, change the setting toNo
. Profile and Release should be set toNo
, and Debug should be set toYes
.
An additional setting may need to be updated when building on a device instead of an emulator. Navigate to the Runner target > Build Settings in Xcode, and in the Build Options section, set Allow Multi-Platform Builds to No
.
In VScode, go to applications/sample/ios/Runner.xcodeproj/project.pbxproj and replace all instances of i386
with i386 arm64
.
-
Update the Xcode bundle identifiers from the defaults provided in the Runner project to
com.acoustic.sample
or to the values you used when you created the provisioning for the sample app in your Apple developer account for the following targets:- Runner
in the General tab, update the following:
– Bundle Identifier: com.acoustic.sample
in the Signing & Capabilities tab, update the following:
– Bundle Identifier: com.acoustic.sample
– App Groups: group.com.acoustic.sample
– Keychain Sharing: com.acoustic.sample - Notification Service
in the General tab, update the following:
– Bundle Identifier: com.acoustic.sample.NotificationService
in the Signing & Capabilities tab, update the following:
– Bundle Identifier: com.acoustic.sample.NotificationService
– App Groups: group.com.acoustic.sample
– Keychain Sharing: com.acoustic.sample
- Runner
-
Using the terminal in VSCode, from the root directory of the SDK folder, change the directory to cd applications/sample/ios.
-
Run
pod install
. -
Make sure an emulator/device is connected to VSCode.
-
Build the project from applications/sample/lib/main.dart file. Right-click on the main.dart file and click Start Debugging.
If the emulator fails to build, you must clean and rebuild the project as follows:
a. Using the terminal in VSCode, from the root directory of the SDK folder, change the directory to cd applications/sample.
b)Run the following commands in the order provided, allowing time for each command to complete before proceeding to the next:
flutter channel stable
flutter upgrade
flutter pub upgrade
c. Run the flutter pub get
command to re-update the dependencies.
d. Change the directory to applications/sample/ios.
e. Run the pod install
command.
f. Build the project again from applications/sample/lib/main.dart file. Right-click on the main.dart file and click Start Debugging.
Updated over 1 year ago