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

Release 6.7.0 #56

Merged
merged 18 commits into from
Apr 24, 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
12 changes: 12 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Publish to pub.dev

on: workflow_dispatch
# push:
# tags:
# - 'v[0-9]+.[0-9]+.[0-9]+*'

jobs:
publish:
permissions:
id-token: write # Required for authentication using OIDC
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
6 changes: 3 additions & 3 deletions .scripts/changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- Apptentive Android SDK: 6.5.0
- Apptentive iOS SDK: 6.5.0
- Apptentive Android SDK: 6.7.0
- Apptentive iOS SDK: 6.7.0

#### Bugs Fixed:

- Fixed an issue where calling register multiple times would hang on Android builds
- Added missing implementation of `handleGetUnreadMessageCount` for iOS
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 2024-04-24 - v6.7.0

- Apptentive Android SDK: 6.7.0
- Apptentive iOS SDK: 6.7.0

#### Bugs Fixed:

- Added missing implementation of `handleGetUnreadMessageCount` for iOS

# 2023-11-17 - v6.2.2

- Apptentive Android SDK: 6.5.0
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ android {
}

dependencies {
implementation 'com.apptentive:apptentive-kit-android:6.5.0'
implementation 'com.apptentive:apptentive-kit-android:6.7.0'
testImplementation 'junit:junit:4.13.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ class ApptentiveFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware
}
}

private val authenticationFailedListener = object : AuthenticationFailedListener {
override fun onAuthenticationFailed(reason: AuthenticationFailedReason) {
Log.e(LogTag("Flutter"), "Authentication failed: $reason")
activity?.runOnUiThread {
channel.invokeMethod("onAuthenticationFailed", mapOf("errorMessage" to reason.toString()))
}
}
}

//region lifecycle methods

// When plugin is attached, set and connect method channel
Expand Down Expand Up @@ -110,6 +119,10 @@ class ApptentiveFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware
"sendAttachmentText" -> sendAttachmentText(call, result)
"isSDKRegistered" -> isSDKRegistered(result)
"handleRequestPushPermissions" -> { /* Only iOS. */ }
"login" -> login(call, result)
"setAuthenticationFailedListener" -> setAuthenticationFailedListener(result)
"updateToken" -> updateToken(call, result)
"logout" -> logout(result)
else -> result.notImplemented()
}
}
Expand Down Expand Up @@ -374,6 +387,59 @@ class ApptentiveFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware
}
}

private fun login(call: MethodCall, result: Result) {
val token: String? = call.argument("token")
if (token == null) {
result.error(ERROR_CODE, "Failed to login: Token is null.", null)
return
}
try {
Apptentive.login(token) { loginResult ->
when (loginResult) {
is LoginResult.Success -> result.success(true)
else -> result.error(ERROR_CODE, "Failed to login", null)
}
}
} catch (e: Exception) {
result.error(ERROR_CODE, "Failed to login.", e.toString())
}
}

private fun setAuthenticationFailedListener(result: Result) {
try {
Apptentive.setAuthenticationFailedListener(authenticationFailedListener)
} catch (e: Exception) {
result.error(ERROR_CODE, "Failed to set authentication failed listener.", e.toString())
}
}

private fun updateToken(call: MethodCall, result: Result) {
val token: String? = call.argument("token")
if (token == null) {
result.error(ERROR_CODE, "Failed to update token: Token is null.", null)
return
}
try {
Apptentive.updateToken(token) { loginResult ->
when (loginResult) {
is LoginResult.Success -> result.success(true)
else -> result.error(ERROR_CODE, "Failed to update token", null)
}
}
} catch (e: Exception) {
result.error(ERROR_CODE, "Failed to update token.", e.toString())
}
}

private fun logout(result: Result) {
try {
Apptentive.logout()
result.success(true)
} catch (e: Exception) {
result.error(ERROR_CODE, "Failed to logout.", e.toString())
}
}

private fun messageObserver(notification: MessageCenterNotification?) {
val notificationText =
"Can Show Message Center: ${notification?.canShowMessageCenter}. " +
Expand Down
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31
compileSdkVersion 33

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.apptentive.apptentive_flutter_example"
minSdkVersion 21
targetSdkVersion 31
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>13.0</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '11.0'
platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down Expand Up @@ -37,7 +37,7 @@ post_install do |installer|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13'
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = ''
end
end
Expand Down
9 changes: 5 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -239,6 +239,7 @@
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down Expand Up @@ -363,7 +364,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -443,7 +444,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -493,7 +494,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
26 changes: 25 additions & 1 deletion ios/Classes/ApptentiveFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class ApptentiveFlutterPlugin: NSObject, FlutterApplicationLifeCycleDeleg
case "setPushNotificationIntegration": handleSetPushNotificationIntegrationCall(call, result)
case "registerListeners": handleRegisterListenersCall(call, result)
case "sendAttachmentText": handleSendAttachmentTextCall(call, result)
case "login": handleLoginCall(call, result)
case "logout": handleLogoutCall(result)
default: result(FlutterMethodNotImplemented)
}
}
Expand Down Expand Up @@ -141,7 +143,7 @@ public class ApptentiveFlutterPlugin: NSObject, FlutterApplicationLifeCycleDeleg

// Get the number of unread messages in Message Center
private func handleGetUnreadMessageCount(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
// TODO
result(Apptentive.shared.unreadMessageCount)
}

// Set person name
Expand Down Expand Up @@ -270,6 +272,28 @@ public class ApptentiveFlutterPlugin: NSObject, FlutterApplicationLifeCycleDeleg
result(true)
}

private func handleLoginCall(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
guard let callArguments = call.arguments as? [String: String], let token = callArguments["token"] else {
return result(FlutterError.init(code: Self.errorCode, message: "Expected String for token.", details: nil))
}
Apptentive.shared.logIn(with: token,
completion: { (completionResult) -> Void in
switch completionResult {
case .success:
result(true)
case .failure(let error):
result(FlutterError.init(code: Self.errorCode, message: "Apptentive SDK failed to login.", details: error.localizedDescription))
}
})
result(true)
}

private func handleLogoutCall(_ result: @escaping FlutterResult) {
Apptentive.shared.logOut()
result(true)
}


@objc func eventEngaged(notification: Notification) {
guard let userInfo = notification.userInfo as? [String: String],
let event = userInfo["eventType"]
Expand Down
4 changes: 2 additions & 2 deletions ios/apptentive_flutter.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'apptentive_flutter'
s.version = "6.2.2"
s.version = "6.7.0"
s.summary = 'Apptentive SDK for Flutter'
s.description = <<-DESC
Apptentive SDK for Flutter
Expand All @@ -12,7 +12,7 @@ Apptentive SDK for Flutter
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.dependency 'ApptentiveKit', '6.5.0'
s.dependency 'ApptentiveKit', '6.7.0'
s.platform = :ios, '13.0'

# Flutter.framework does not contain a i386 slice.
Expand Down
32 changes: 31 additions & 1 deletion lib/apptentive_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ApptentiveConfiguration {
this.shouldEncryptStorage = false,
this.shouldSanitizeLogMessages = true,
this.distributionName = "Flutter",
this.distributionVersion = "6.2.2",
this.distributionVersion = "6.7.0",
this.ratingInteractionThrottleLength = 604800000, // 1 week
this.customAppStoreURL
});
Expand All @@ -33,6 +33,7 @@ enum PushProvider { apptentive, amazon, parse, urban_airship }
typedef SurveyFinishedCallback = void Function(bool completed);
typedef MessageCenterUnreadCountChangedNotification = void Function(int count);
typedef MessageSentNotification = void Function(String sentByUser);
typedef AuthenticationFailedNotification = void Function(String errorMessage);

// Plugin class
class ApptentiveFlutter {
Expand All @@ -43,6 +44,7 @@ class ApptentiveFlutter {
static SurveyFinishedCallback? surveyFinishedCallback;
static MessageCenterUnreadCountChangedNotification? messageCenterUnreadCountChangedNotification;
static MessageSentNotification? messageSentNotification;
static AuthenticationFailedNotification? authenticationFailedNotification;

// Handle callbacks from Native
static Future<dynamic> _nativeCallback(MethodCall methodCall) async {
Expand All @@ -60,6 +62,10 @@ class ApptentiveFlutter {
String sentByUser = methodCall.arguments["sentByUser"];
messageSentNotification?.call(sentByUser);
break;
case 'onAuthenticationFailed':
String errorMessage = methodCall.arguments["errorMessage"];
authenticationFailedNotification?.call(errorMessage);
break;
default:
throw MissingPluginException('notImplemented');
}
Expand Down Expand Up @@ -198,6 +204,30 @@ class ApptentiveFlutter {
return registered;
}

static Future<bool> login({required String token}) async {
final bool successful = await _channel.invokeMethod('login', {
"token": token
});
return successful;
}

static Future<bool> logout() async {
final bool successful = await _channel.invokeMethod('logout', {});
return successful;
}

static Future<bool> updateToken({required String token}) async {
final bool successful = await _channel.invokeMethod('updateToken', {
"token": token
});
return successful;
}

static Future<bool> setAuthenticationFailedListener() async {
final bool successful = await _channel.invokeMethod('setAuthenticationFailedListener', {});
return successful;
}

// Pack the Apptentive Configuration into a map object <String, Any>
static Map _packConfiguration(ApptentiveConfiguration configuration) {
return {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: apptentive_flutter
description: Apptentive SDK for Flutter
version: 6.2.2
version: 6.7.0
repository: https://github.com/apptentive/apptentive-flutter
issue_tracker: https://github.com/apptentive/apptentive-flutter/issues
documentation: https://learn.apptentive.com/knowledge-base/apptentive-sdk-flutter-plugin-guide/
Expand Down
Loading