Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repo Cleanup #115

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
**.flutter-plugins
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<Your_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 = "<YOUR_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 = "<YOUR_APP_ID>"
```

- 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
<script>
var moeAppID = "<Your_App_ID>";
</script>
```

## 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.
4 changes: 2 additions & 2 deletions core/moengage_flutter/test/moengage_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
48 changes: 0 additions & 48 deletions example/android/app/google-services.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import com.moengage.inapp.MoEInAppHelper
* Date: 2019-12-13
*/
class SampleApplication : FlutterApplication() {

private const val APP_ID = "<YOUR_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,
Expand All @@ -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()
}
}
10 changes: 5 additions & 5 deletions example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<YOUR_APP_ID>" //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
Expand Down
40 changes: 0 additions & 40 deletions example/ios/Runner/GoogleService-Info.plist

This file was deleted.

3 changes: 2 additions & 1 deletion example/lib/cards/cards_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -13,7 +14,7 @@ class CardsHome extends StatefulWidget {
}

class _CardsHomeState extends State<CardsHome> {
moe.MoEngageCards cards = moe.MoEngageCards('DAO6UGZ73D9RTK8B5W96TPYN');
moe.MoEngageCards cards = moe.MoEngageCards(APP_ID);

@override
void initState() {
Expand Down
3 changes: 2 additions & 1 deletion example/lib/cards/cards_screen.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -14,7 +15,7 @@ class _CardsScreenState extends State<CardsScreen>
with TickerProviderStateMixin {
List<moe.Card> cardList = [];

moe.MoEngageCards cards = moe.MoEngageCards('DAO6UGZ73D9RTK8B5W96TPYN');
moe.MoEngageCards cards = moe.MoEngageCards(APP_ID);

List<String> categories = [];

Expand Down
2 changes: 2 additions & 0 deletions example/lib/constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// MoEngage AppId
const String APP_ID = '<Your_App_ID>';
4 changes: 3 additions & 1 deletion example/lib/inapp.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:moengage_flutter/moengage_flutter.dart';

import '../constants.dart';
import 'utils.dart';

/// InApp Screen
Expand All @@ -12,7 +14,7 @@ class InAppHomeScreen extends StatefulWidget {

class _InAppHomeScreenState extends State<InAppHomeScreen> {
final MoEngageFlutter _moengagePlugin =
MoEngageFlutter('DAO6UGZ73D9RTK8B5W96TPYN');
MoEngageFlutter(APP_ID);

static const String tag = 'InAppHomeScreen';

Expand Down
10 changes: 5 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -42,16 +43,15 @@ class MyApp extends StatefulWidget {
}

class _MyAppState extends State<MyApp> 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(
Expand Down Expand Up @@ -490,7 +490,7 @@ class _MyAppState extends State<MyApp> 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');
Expand Down
2 changes: 1 addition & 1 deletion example/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<script src="main.dart.js" type="application/javascript"></script>
<script type="text/javascript">
var moeDataCenter = "dc_1"; // Replace "DC" with the actual Data center value from the above table
var moeAppID = "DAO6UGZ73D9RTK8B5W96TPYN"; // Replace "AppID" available in the settings page of MoEngage Dashboard.
var moeAppID = "<Your_App_ID>"; // Replace "<Your_App_ID>" available in the settings page of MoEngage Dashboard.

!function(e,n,i,t,a,r,o,d){if(!moeDataCenter||"{DC}"===moeDataCenter)return console.error("Data center has not been passed correctly. Please follow the SDK installation instruction carefully.");var s=e[a]=e[a]||[];if(s.invoked=0,s.initialised>0||s.invoked>0)return console.error("MoEngage Web SDK initialised multiple times. Please integrate the Web SDK only once!"),!1;e.moengage_object=a;var l={},g=function n(i){return function(){for(var n=arguments.length,t=Array(n),a=0;a<n;a++)t[a]=arguments[a];(e.moengage_q=e.moengage_q||[]).push({f:i,a:t})}},u=["track_event","add_user_attribute","add_first_name","add_last_name","add_email","add_mobile","add_user_name","add_gender","add_birthday","destroy_session","add_unique_user_id","update_unique_user_id","moe_events","call_web_push","track","location_type_attribute"],m={onsite:["getData","registerCallback"]};for(var c in u)l[u[c]]=g(u[c]);for(var v in m)for(var f in m[v])null==l[v]&&(l[v]={}),l[v][m[v][f]]=g(v+"."+m[v][f]);r=n.createElement(i),o=n.getElementsByTagName("head")[0],r.async=1,r.src=t,o.appendChild(r),e.moe=e.moe||function(){return(s.invoked=s.invoked+1,s.invoked>1)?(console.error("MoEngage Web SDK initialised multiple times. Please integrate the Web SDK only once!"),!1):(d=arguments.length<=0?void 0:arguments[0],l)},r.addEventListener("load",function(){if(d)return e[a]=e.moe(d),e[a].initialised=e[a].initialised+1||1,!0}),r.addEventListener("error",function(){return console.error("Moengage Web SDK loading failed."),!1})}(window,document,"script","https://cdn.moengage.com/release/"+moeDataCenter+"/moe_webSdk.min.latest.js","Moengage");
Moengage = moe({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final InboxData inboxData = InboxData('android', [
'gcm_notificationType': 'gcm_webNotification',
'push_from': 'moengage',
'gcm_webUrl': 'monengage://moe_app/add_to_cart',
'moe_app_id': 'DAO6UGZ73D9RTK8B5W96TPYN_DEBUG',
'moe_app_id': '12345',
'gcm_campaign_id': '000000000000000088470679_L_0',
'moe_channel_id': 'moe_sound_channel',
'moe_webUrl': 'monengage://moe_app/add_to_cart?key=value',
Expand All @@ -33,7 +33,7 @@ final InboxData inboxData = InboxData('android', [
'2023-08-15T06:17:30.167Z',
'2023-11-13T06:17:30.000Z',
{
'moe_app_id': 'DAO6UGZ73D9RTK8B5W96TPYN_DEBUG',
'moe_app_id': '',
'moe_notification_posted_time': 1692080250175,
'gcm_subtext': 'Summary',
'moe_webUrl': 'monengage://moe_app/add_to_cart?key=value',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const String inboxPayload = '''
"gcm_notificationType": "gcm_webNotification",
"push_from": "moengage",
"gcm_webUrl": "monengage://moe_app/add_to_cart",
"moe_app_id": "DAO6UGZ73D9RTK8B5W96TPYN_DEBUG",
"moe_app_id": "12345",
"gcm_campaign_id": "000000000000000088470679_L_0",
"moe_channel_id": "moe_sound_channel",
"moe_webUrl": "monengage://moe_app/add_to_cart?key=value",
Expand All @@ -43,7 +43,7 @@ const String inboxPayload = '''
"expiry": "2023-11-13T06:17:30.000Z",
"tag": "general",
"payload": {
"moe_app_id": "DAO6UGZ73D9RTK8B5W96TPYN_DEBUG",
"moe_app_id": "",
"moe_notification_posted_time": 1692080250175,
"gcm_subtext": "Summary",
"moe_webUrl": "monengage://moe_app/add_to_cart?key=value",
Expand Down