From 390d3812b0c687cb1a50c6d455acb0cc9af2f9c7 Mon Sep 17 00:00:00 2001 From: Gowtham KK Date: Fri, 5 Apr 2024 10:28:28 +0530 Subject: [PATCH] Repo CleanUp --- .gitignore | 4 +- README.md | 54 +++++++++++++++++++ .../test/moengage_flutter_test.dart | 4 +- .../test/data_provider/data_provider.dart | 2 +- .../test/data_provider/json_data.dart | 2 +- example/android/app/google-services.json | 48 ----------------- .../moengage/sampleapp/SampleApplication.kt | 6 ++- example/ios/Runner/AppDelegate.swift | 10 ++-- example/ios/Runner/GoogleService-Info.plist | 40 -------------- example/lib/cards/cards_home.dart | 3 +- example/lib/cards/cards_screen.dart | 3 +- example/lib/constants.dart | 2 + example/lib/inapp.dart | 4 +- example/lib/main.dart | 10 ++-- example/web/index.html | 2 +- .../test/src/data_provider_provider.dart | 4 +- .../test/src/json_data_provider.dart | 4 +- 17 files changed, 89 insertions(+), 113 deletions(-) delete mode 100644 example/android/app/google-services.json delete mode 100644 example/ios/Runner/GoogleService-Info.plist create mode 100644 example/lib/constants.dart diff --git a/.gitignore b/.gitignore index cf196254..b10eae34 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,9 @@ build/ android/.settings exampleObjC example/android/app/local.properties +example/android/app/google-services.json +example/ios/Runner/GoogleService-Info.plist **pubspec.lock /geofence/example/android/gradle/wrapper/gradle-wrapper.jar **.flutter-plugins-dependencies -**.flutter-plugins \ No newline at end of file +**.flutter-plugins diff --git a/README.md b/README.md index 45d8bcb6..72031c2c 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,57 @@ This repository contains the Flutter plugins for the [MoEngage](https://www.moen | geofence | Contains the implementation for the SDK implementation for Geofence Feature | +# How to run the sample application? + +## Update MoEngage App ID + +Before running the sample application, you need to update your MoEngage app-id in various files as follows: + +### Dart + +- In the `example/lib/constants.dart` file, update the `APP_ID` constant with your actual App ID from the MoEngage Dashboard. + + ```dart + const String APP_ID = ''; + ``` + +### Android + +- In the `example/android/app/src/main/com/moengage/sampleapp/SampleApplication.kt` file, update the `APP_ID` constant with your actual App ID. + + ```kotlin + private const val APP_ID = "" + ``` + +- Place your `google-services.json` file in the `example/android/app` directory. + +### iOS + +- In the `example/ios/Runner/AppDelegate.swift` file, update the `yourAppID` variable with your actual App ID. + + ```swift + let yourAppID = "" + ``` + +- Add your `GoogleService-Info.plist` file to the `example/ios/Runner` directory. + +### Web + +- In the `example/web/index.html` file, update the `moeAppID` variable with your actual App ID. + + ```html + + ``` + +## Running the Application + +After updating the App ID and placing the necessary platform-specific files, follow the instructions below to run the application: + +1. Open the terminal and navigate to the `example` directory. +2. Run `flutter pub get` to fetch all the dependencies. +3. To run on Android or iOS, connect a device or start an emulator. +4. Run the application with `flutter run` for your targeted platform. + +Ensure that you have set up the development environment for Flutter and the respective platform you are targeting (Android Studio/Xcode for Android/iOS, updated web browser for Web) before attempting to run the sample application. \ No newline at end of file diff --git a/core/moengage_flutter/test/moengage_flutter_test.dart b/core/moengage_flutter/test/moengage_flutter_test.dart index eb040c97..86a2fa2e 100644 --- a/core/moengage_flutter/test/moengage_flutter_test.dart +++ b/core/moengage_flutter/test/moengage_flutter_test.dart @@ -12,7 +12,7 @@ void main() { tearDown(() => {mock.clear()}); test('User Attributes set', () async { - final platform = MoEngageFlutter('DAO6UGZ73D9RTK8B5W96TPYN'); + final platform = MoEngageFlutter('12345'); for (final entry in setUserAttributesData.entries) { platform.setUserAttribute(entry.key, entry.value); expect(mock.setUserAttributeLastUserAttributeName, entry.key); @@ -21,7 +21,7 @@ void main() { }); test('User Attributes not set', () async { - final platform = MoEngageFlutter('DAO6UGZ73D9RTK8B5W96TPYN'); + final platform = MoEngageFlutter('12345'); for (final entry in unsetUserAttributesData.entries) { platform.setUserAttribute(entry.key, entry.value); expect(mock.setUserAttributeLastUserAttributeName, null); diff --git a/core/moengage_flutter_platform_interface/test/data_provider/data_provider.dart b/core/moengage_flutter_platform_interface/test/data_provider/data_provider.dart index 5851ed20..b7d2ae4d 100644 --- a/core/moengage_flutter_platform_interface/test/data_provider/data_provider.dart +++ b/core/moengage_flutter_platform_interface/test/data_provider/data_provider.dart @@ -31,7 +31,7 @@ final PushCampaignData pushCampaignData = PushCampaignData( 'gcm_notificationType': 'gcm_webNotification', 'push_from': 'moengage', 'gcm_webUrl': 'monengage://moe_app/add_to_cart', - 'moe_app_id': 'DAO6UGZ73D9RTK8B5W96TPYN_DEBUG', + 'moe_app_id': '', 'gcm_campaign_id': '000000000000000015056066_L_0', 'moe_channel_id': 'moe_sound_channel', 'moe_webUrl': 'monengage://moe_app/add_to_cart?key=value', diff --git a/core/moengage_flutter_platform_interface/test/data_provider/json_data.dart b/core/moengage_flutter_platform_interface/test/data_provider/json_data.dart index 950cef34..839f334d 100644 --- a/core/moengage_flutter_platform_interface/test/data_provider/json_data.dart +++ b/core/moengage_flutter_platform_interface/test/data_provider/json_data.dart @@ -314,7 +314,7 @@ const String pushCampaignPayload = ''' "gcm_notificationType": "gcm_webNotification", "push_from": "moengage", "gcm_webUrl": "monengage://moe_app/add_to_cart", - "moe_app_id": "DAO6UGZ73D9RTK8B5W96TPYN_DEBUG", + "moe_app_id": "", "gcm_campaign_id": "000000000000000015056066_L_0", "moe_channel_id": "moe_sound_channel", "moe_webUrl": "monengage://moe_app/add_to_cart?key=value", diff --git a/example/android/app/google-services.json b/example/android/app/google-services.json deleted file mode 100644 index e9f02a26..00000000 --- a/example/android/app/google-services.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "project_info": { - "project_number": "615448685370", - "firebase_url": "https://moesampleapp.firebaseio.com", - "project_id": "moesampleapp", - "storage_bucket": "moesampleapp.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:615448685370:android:6d75bcba72eb0cc3", - "android_client_info": { - "package_name": "com.moengage.sampleapp" - } - }, - "oauth_client": [ - { - "client_id": "615448685370-t44jadhvvl6rbquccpmcuftu4a7obfui.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.moengage.sampleapp", - "certificate_hash": "bb66a47ede36191adbca2fd8061aa3ef019a7a00" - } - }, - { - "client_id": "615448685370-bs2ol993hu6u6kq14gsn24uage57mi4u.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCyKHUkkxH537ojYCaRXQ3_pp9EY9Sk88E" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "615448685370-bs2ol993hu6u6kq14gsn24uage57mi4u.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - } - ], - "configuration_version": "1" -} \ No newline at end of file diff --git a/example/android/app/src/main/java/com/moengage/sampleapp/SampleApplication.kt b/example/android/app/src/main/java/com/moengage/sampleapp/SampleApplication.kt index 5b5e1c6d..9d2e5996 100644 --- a/example/android/app/src/main/java/com/moengage/sampleapp/SampleApplication.kt +++ b/example/android/app/src/main/java/com/moengage/sampleapp/SampleApplication.kt @@ -20,9 +20,11 @@ import com.moengage.inapp.MoEInAppHelper * Date: 2019-12-13 */ class SampleApplication : FlutterApplication() { + + private const val APP_ID = "" override fun onCreate() { super.onCreate() - val moEngage: MoEngage.Builder = MoEngage.Builder(this, "DAO6UGZ73D9RTK8B5W96TPYN") + val moEngage: MoEngage.Builder = MoEngage.Builder(this, APP_ID) .configureNotificationMetaData( NotificationConfig( R.drawable.icon, @@ -39,7 +41,7 @@ class SampleApplication : FlutterApplication() { .configureMoEngageEnvironment(MoEngageEnvironmentConfig(MoEngageEnvironment.DEFAULT)) MoEInitializer.initialiseDefaultInstance(applicationContext, moEngage, SdkState.ENABLED,true) // optional, required in-case notification customisation is required. - MoEPushHelper.getInstance().registerMessageListener(CustomPushListener(AccountMeta("DAO6UGZ73D9RTK8B5W96TPYN"))) + MoEPushHelper.getInstance().registerMessageListener(CustomPushListener(AccountMeta(APP_ID))) MoEInAppHelper.getInstance().enableActivityRegistrationOnResume() } } \ No newline at end of file diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index d83c1df9..c176a7ab 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -6,24 +6,24 @@ import MoEngageInApps @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { - + override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { - - let yourAppID = "DAO6UGZ73D9RTK8B5W96TPYN" //App ID: You can be obtain it from App Settings in MoEngage Dashboard. + + let yourAppID = "" //App ID: You can be obtain it from App Settings in MoEngage Dashboard. let sdkConfig = MoEngageSDKConfig(withAppID: yourAppID) sdkConfig.appGroupID = "group.com.alphadevs.MoEngage.NotificationServices" sdkConfig.consoleLogConfig = MoEngageConsoleLogConfig(isLoggingEnabled: true, loglevel: .verbose) - + MoEngageSDKCore.sharedInstance.enableAllLogs() MoEngageInitializer.sharedInstance.initializeDefaultInstance(sdkConfig, launchOptions: launchOptions) GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } - + override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { print("Opening deeplink", url) return true diff --git a/example/ios/Runner/GoogleService-Info.plist b/example/ios/Runner/GoogleService-Info.plist deleted file mode 100644 index 7f745ea4..00000000 --- a/example/ios/Runner/GoogleService-Info.plist +++ /dev/null @@ -1,40 +0,0 @@ - - - - - AD_UNIT_ID_FOR_BANNER_TEST - ca-app-pub-3940256099942544/2934735716 - AD_UNIT_ID_FOR_INTERSTITIAL_TEST - ca-app-pub-3940256099942544/4411468910 - CLIENT_ID - 559753655227-mqfi4o4fejqi0cfhhglgg6ngu73fd9j5.apps.googleusercontent.com - REVERSED_CLIENT_ID - com.googleusercontent.apps.559753655227-mqfi4o4fejqi0cfhhglgg6ngu73fd9j5 - API_KEY - AIzaSyBBbhBuR40Vd6JKZb5b3aUBjVCdP4W9Ns8 - GCM_SENDER_ID - 559753655227 - PLIST_VERSION - 1 - BUNDLE_ID - com.alphadevs.MoEngage - PROJECT_ID - moedemo-93e2e - STORAGE_BUCKET - moedemo-93e2e.appspot.com - IS_ADS_ENABLED - - IS_ANALYTICS_ENABLED - - IS_APPINVITE_ENABLED - - IS_GCM_ENABLED - - IS_SIGNIN_ENABLED - - GOOGLE_APP_ID - 1:559753655227:ios:522230ce3e404cf6 - DATABASE_URL - https://moedemo-93e2e.firebaseio.com - - diff --git a/example/lib/cards/cards_home.dart b/example/lib/cards/cards_home.dart index 758895ef..c11efdeb 100644 --- a/example/lib/cards/cards_home.dart +++ b/example/lib/cards/cards_home.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:moengage_cards/moengage_cards.dart' as moe; +import '../constants.dart'; import 'cards_screen.dart'; class CardsHome extends StatefulWidget { @@ -13,7 +14,7 @@ class CardsHome extends StatefulWidget { } class _CardsHomeState extends State { - moe.MoEngageCards cards = moe.MoEngageCards('DAO6UGZ73D9RTK8B5W96TPYN'); + moe.MoEngageCards cards = moe.MoEngageCards(APP_ID); @override void initState() { diff --git a/example/lib/cards/cards_screen.dart b/example/lib/cards/cards_screen.dart index 36575d9e..1c9e94bb 100644 --- a/example/lib/cards/cards_screen.dart +++ b/example/lib/cards/cards_screen.dart @@ -1,6 +1,7 @@ // ignore_for_file: public_member_api_docs import 'package:flutter/material.dart'; import 'package:moengage_cards/moengage_cards.dart' as moe; +import '../constants.dart'; import 'card_widget.dart'; class CardsScreen extends StatefulWidget { @@ -14,7 +15,7 @@ class _CardsScreenState extends State with TickerProviderStateMixin { List cardList = []; - moe.MoEngageCards cards = moe.MoEngageCards('DAO6UGZ73D9RTK8B5W96TPYN'); + moe.MoEngageCards cards = moe.MoEngageCards(APP_ID); List categories = []; diff --git a/example/lib/constants.dart b/example/lib/constants.dart new file mode 100644 index 00000000..1a2c2d09 --- /dev/null +++ b/example/lib/constants.dart @@ -0,0 +1,2 @@ +/// MoEngage AppId +const String APP_ID = ''; diff --git a/example/lib/inapp.dart b/example/lib/inapp.dart index fd25321e..8f67656f 100644 --- a/example/lib/inapp.dart +++ b/example/lib/inapp.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; import 'package:moengage_flutter/moengage_flutter.dart'; + +import '../constants.dart'; import 'utils.dart'; /// InApp Screen @@ -12,7 +14,7 @@ class InAppHomeScreen extends StatefulWidget { class _InAppHomeScreenState extends State { final MoEngageFlutter _moengagePlugin = - MoEngageFlutter('DAO6UGZ73D9RTK8B5W96TPYN'); + MoEngageFlutter(APP_ID); static const String tag = 'InAppHomeScreen'; diff --git a/example/lib/main.dart b/example/lib/main.dart index 18e1a884..0caf23f4 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -7,6 +7,7 @@ import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:moengage_flutter/moengage_flutter.dart'; +import 'package:moengage_flutter_example/constants.dart'; import 'package:moengage_geofence/moengage_geofence.dart'; import 'package:moengage_inbox/moengage_inbox.dart'; import 'package:permission_handler/permission_handler.dart'; @@ -42,16 +43,15 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State with WidgetsBindingObserver { - final MoEngageFlutter _moengagePlugin = MoEngageFlutter( - 'DAO6UGZ73D9RTK8B5W96TPYN', + final MoEngageFlutter _moengagePlugin = MoEngageFlutter(APP_ID, moEInitConfig: MoEInitConfig( pushConfig: PushConfig(shouldDeliverCallbackOnForegroundClick: true), analyticsConfig: AnalyticsConfig(shouldTrackUserAttributeBooleanAsNumber: false))); final MoEngageGeofence _moEngageGeofence = - MoEngageGeofence('DAO6UGZ73D9RTK8B5W96TPYN'); + MoEngageGeofence(APP_ID); final MoEngageInbox _moEngageInbox = - MoEngageInbox('DAO6UGZ73D9RTK8B5W96TPYN'); + MoEngageInbox(APP_ID); void _onPushClick(PushCampaignData message) { debugPrint( @@ -490,7 +490,7 @@ class _MyAppState extends State with WidgetsBindingObserver { pushPayload.putIfAbsent('push_from', () => 'moengage'); pushPayload.putIfAbsent('gcm_title', () => 'Title'); pushPayload.putIfAbsent( - 'moe_app_id', () => 'DAO6UGZ73D9RTK8B5W96TPYN'); + 'moe_app_id', () => APP_ID); pushPayload.putIfAbsent( 'gcm_notificationType', () => 'normal notification'); pushPayload.putIfAbsent('gcm_alert', () => 'Message'); diff --git a/example/web/index.html b/example/web/index.html index 5d997ea8..de848f24 100644 --- a/example/web/index.html +++ b/example/web/index.html @@ -43,7 +43,7 @@