Skip to content

Commit

Permalink
Merge branch 'notifications'
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Nov 30, 2024
2 parents c4dd9f8 + cf9274a commit 86a12d8
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 10 deletions.
6 changes: 5 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ plugins {
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "io.sentry.android.gradle"
id 'com.google.gms.google-services'

}

def localProperties = new Properties()
Expand Down Expand Up @@ -102,6 +104,8 @@ dependencies {
testImplementation "junit:junit:4.13.2"
// https://developer.android.com/jetpack/androidx/releases/test/#1.2.0
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.3"
implementation(platform("com.google.firebase:firebase-bom:33.6.0"))

}
configurations.configureEach {
exclude group: "io.sentry", module: "sentry-android-ndk"
Expand All @@ -111,7 +115,7 @@ sentry {
// Disables or enables debug log output, e.g. for for sentry-cli.
// Default is disabled.
debug = false

// The slug of the Sentry organization to use for uploading proguard mappings/source contexts.
org = System.getenv("SENTRY_ORG")

Expand Down
24 changes: 24 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,30 @@
android:exported="false"
android:foregroundServiceType="connectedDevice"
android:stopWithTask="true" />


<service
android:name="com.klaviyo.pushFcm.KlaviyoPushService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="Marketing" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_notification" />
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
notification message. See README(https://goo.gl/6BKBk7) for more. -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#E46E26" />
<meta-data
android:name="firebase_messaging_auto_init_enabled"
android:value="false" />
</application>
<!-- Provide required visibility configuration for API level 30 and above -->
<queries>
Expand Down
2 changes: 2 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ plugins {
id "io.sentry.android.gradle" version "4.13.0" apply false
id "org.jetbrains.kotlin.android" version "2.0.21" apply false
id "com.android.application" version '8.7.2' apply false
id 'com.google.gms.google-services' version '4.4.2' apply false

}

include ":app"
Expand Down
3 changes: 3 additions & 0 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import Flutter
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
31 changes: 31 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'dart:ui';

import 'package:device_info_plus/device_info_plus.dart';
import 'package:feedback_sentry/feedback_sentry.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:firebase_testlab_detector/firebase_testlab_detector.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
Expand All @@ -15,6 +17,7 @@ import 'package:hive_flutter/adapters.dart';
import 'package:install_referrer/install_referrer.dart';
import 'package:intl/intl.dart';
import 'package:is_wear/is_wear.dart';
import 'package:klaviyo_flutter/klaviyo_flutter.dart';
import 'package:logging/logging.dart';
import 'package:path_provider/path_provider.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
Expand Down Expand Up @@ -439,3 +442,31 @@ class _EagerInitialization extends ConsumerWidget {
return child;
}
}

//TODO: get APNs cert from apple
// Eat snacks
// Get google-services.json
// Configure Github Actions to store and place the files
Future<void> initMarketingNotifications() async {
await Klaviyo.instance.initialize(const String.fromEnvironment('KLAVIYO_KEY', defaultValue: ""));
final firebaseMessaging = FirebaseMessaging.instance;
final token = Platform.isIOS ? await firebaseMessaging.getAPNSToken() : await firebaseMessaging.getToken();

if (token != null && token.isNotEmpty) {
Klaviyo.instance.sendTokenToKlaviyo(token);
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
}
}

Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
final data = message.data;
final klaviyo = Klaviyo.instance;

if (klaviyo.isKlaviyoPush(data)) {
if (!klaviyo.isInitialized) {
await klaviyo.initialize(const String.fromEnvironment('KLAVIYO_KEY', defaultValue: ""));
}
final result = await klaviyo.handlePush(data);
}
}
80 changes: 72 additions & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "72.0.0"
_flutterfire_internals:
dependency: transitive
description:
name: _flutterfire_internals
sha256: "71c01c1998c40b3af1944ad0a5f374b4e6fef7f3d2df487f3970dbeadaeb25a1"
url: "https://pub.dev"
source: hosted
version: "1.3.46"
_macros:
dependency: transitive
description: dart
Expand Down Expand Up @@ -543,6 +551,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "8.1.4"
firebase_core:
dependency: "direct main"
description:
name: firebase_core
sha256: "2438a75ad803e818ad3bd5df49137ee619c46b6fc7101f4dbc23da07305ce553"
url: "https://pub.dev"
source: hosted
version: "3.8.0"
firebase_core_platform_interface:
dependency: transitive
description:
name: firebase_core_platform_interface
sha256: e30da58198a6d4b49d5bce4e852f985c32cb10db329ebef9473db2b9f09ce810
url: "https://pub.dev"
source: hosted
version: "5.3.0"
firebase_core_web:
dependency: transitive
description:
name: firebase_core_web
sha256: f967a7138f5d2ffb1ce15950e2a382924239eaa521150a8f144af34e68b3b3e5
url: "https://pub.dev"
source: hosted
version: "2.18.1"
firebase_messaging:
dependency: "direct main"
description:
name: firebase_messaging
sha256: "4d0968ecb860d7baa15a6e2af3469ec5b0d959e51c59ce84a52b0f7632a4aa5a"
url: "https://pub.dev"
source: hosted
version: "15.1.5"
firebase_messaging_platform_interface:
dependency: transitive
description:
name: firebase_messaging_platform_interface
sha256: a2cb3e7d71d40b6612e2d4e0daa0ae759f6a9d07f693f904d14d22aadf70be10
url: "https://pub.dev"
source: hosted
version: "4.5.48"
firebase_messaging_web:
dependency: transitive
description:
name: firebase_messaging_web
sha256: "1554e190f0cd9d6fe59f61ae0275ac12006fdb78b07669f1a260d1a9e6de3a1f"
url: "https://pub.dev"
source: hosted
version: "3.9.4"
firebase_testlab_detector:
dependency: "direct main"
description:
Expand Down Expand Up @@ -718,10 +774,10 @@ packages:
dependency: "direct main"
description:
name: flutter_markdown
sha256: "999a4e3cb3e1532a971c86d6c73a480264f6a687959d4887cb4e2990821827e4"
sha256: "255b00afa1a7bad19727da6a7780cf3db6c3c12e68d302d85e0ff1fdf173db9e"
url: "https://pub.dev"
source: hosted
version: "0.7.4+2"
version: "0.7.4+3"
flutter_native_splash:
dependency: "direct main"
description:
Expand Down Expand Up @@ -758,10 +814,10 @@ packages:
dependency: transitive
description:
name: flutter_svg
sha256: "936d9c1c010d3e234d1672574636f3352b4941ca3decaddd3cafaeb9ad49c471"
sha256: "54900a1a1243f3c4a5506d853a2b5c2dbc38d5f27e52a52618a8054401431123"
url: "https://pub.dev"
source: hosted
version: "2.0.15"
version: "2.0.16"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -1053,6 +1109,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.9.0"
klaviyo_flutter:
dependency: "direct main"
description:
name: klaviyo_flutter
sha256: "0ebeadf99f22b6a9456bc8b87f82663e82ee2862360709a0c284057f286b9b61"
url: "https://pub.dev"
source: hosted
version: "0.1.1"
leak_tracker:
dependency: transitive
description:
Expand Down Expand Up @@ -1258,10 +1322,10 @@ packages:
dependency: transitive
description:
name: path_provider_android
sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a
sha256: "8c4967f8b7cb46dc914e178daa29813d83ae502e0529d7b0478330616a691ef7"
url: "https://pub.dev"
source: hosted
version: "2.2.12"
version: "2.2.14"
path_provider_foundation:
dependency: transitive
description:
Expand Down Expand Up @@ -1937,10 +2001,10 @@ packages:
dependency: transitive
description:
name: vector_graphics_compiler
sha256: ab9ff38fc771e9ee1139320adbe3d18a60327370c218c60752068ebee4b49ab1
sha256: "1b4b9e706a10294258727674a340ae0d6e64a7231980f9f9a3d12e4b42407aad"
url: "https://pub.dev"
source: hosted
version: "1.1.15"
version: "1.1.16"
vector_math:
dependency: "direct main"
description:
Expand Down
5 changes: 4 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ dependencies:
flutter_widget_from_html_core: ^0.15.2
visibility_detector: ^0.4.0+2 # used on the tail blog widgets
lottie: ^3.1.3
#pdfrx: ^1.0.91
pdfx:
git:
url: https://github.com/Codel1417/packages.flutter
path: packages/pdfx

# Dio HTTP
dio: ^5.7.0
dio_smart_retry: ^7.0.1
Expand All @@ -111,9 +111,12 @@ dependencies:
in_app_review: ^2.0.10
upgrader: ^11.3.0
google_api_availability: ^5.0.0
firebase_messaging: ^15.1.5
firebase_core: ^3.8.0

# Spicy
plausible_analytics: ^0.3.0 # Privacy Preserving analytics
klaviyo_flutter: ^0.1.1 # Marketing Notifications

# Sentry
sentry_flutter: ^8.10.1 # Base sentry + Flutter integration
Expand Down

0 comments on commit 86a12d8

Please sign in to comment.