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

Update fcm #276

Merged
merged 8 commits into from
Nov 6, 2024
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Added a flag `enablePreviousNameRecording` to add previous event/view and current view names as segmentation (Experimental!)
* Added a flag `enableVisibilityTracking` to add app visibility info to views (Experimental!)

* Updated the underlying Firebase Messaging SDK to version 24.0.3

* Mitigated an issue where an event was not recorded if a `count` was not provided.
* Fixed an issue where automatic crash reporting failed to capture Flutter framework errors when using the newly introduced config option.
* Addressed an issue where asynchronous Dart errors were not being captured.
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ android {

dependencies {
implementation 'ly.count.android:sdk:24.7.4'
implementation 'com.google.firebase:firebase-messaging:20.2.1'
implementation 'com.google.firebase:firebase-messaging:24.0.3'
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
import ly.count.android.sdk.StarRatingCallback;
import ly.count.android.sdk.messaging.CountlyPush;

import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;
import com.google.firebase.messaging.FirebaseMessaging;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.firebase.FirebaseApp;
Expand Down Expand Up @@ -440,18 +439,19 @@ else if ("setHttpPostForced".equals(call.method)) {
}
CountlyPush.init(activity.getApplication(), pushTokenType);
FirebaseApp.initializeApp(context);
FirebaseInstanceId.getInstance().getInstanceId()
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
@Override
public void onComplete(@NonNull Task<InstanceIdResult> task) {
if (!task.isSuccessful()) {
log("[askForNotificationPermission], getInstanceId failed", task.getException(), LogLevel.WARNING);
return;
}
String token = task.getResult().getToken();
CountlyPush.onTokenRefresh(token);
}
});
FirebaseMessaging.getInstance().getToken().addOnCompleteListener(new OnCompleteListener<String>() {
@Override
public void onComplete(@NonNull Task<String> task) {
if (!task.isSuccessful()) {
log("[askForNotificationPermission], Fetching FCM registration token failed", task.getException(), LogLevel.WARNING);
return;
}

String token = task.getResult();
log("FCM Token: " + token, LogLevel.INFO);
CountlyPush.onTokenRefresh(token);
}
});
result.success("askForNotificationPermission!");
} else if ("pushTokenType".equals(call.method)) {
String tokenType = args.getString(0);
Expand Down
8 changes: 5 additions & 3 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id "com.android.application"
id 'com.google.gms.google-services'
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
Expand All @@ -23,7 +24,7 @@ if (flutterVersionName == null) {
}

android {
namespace "com.example.example"
namespace "com.countly.demo"
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

Expand All @@ -42,7 +43,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
applicationId "com.countly.demo"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21
Expand All @@ -65,7 +66,8 @@ flutter {
}

dependencies {
constraints {
implementation 'com.google.firebase:firebase-messaging:24.0.3'
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
Expand Down
5 changes: 4 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.countly.demo">
<queries>
<package android:name="com.countly.demo" />
</queries>
<application
android:label="example"
android:name="${applicationName}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.example
package com.countly.demo

import io.flutter.embedding.android.FlutterActivity

Expand Down
39 changes: 21 additions & 18 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
delete rootProject.buildDir
}
plugins {
id 'com.google.gms.google-services' version '4.3.15' apply false
}
allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
delete rootProject.buildDir
}