Skip to content

Commit

Permalink
Client email navigation (meditohq#494)
Browse files Browse the repository at this point in the history
* chore: device and user info added in client email
  • Loading branch information
osamaasifoak authored Oct 6, 2023
1 parent 447e79b commit e2165d0
Show file tree
Hide file tree
Showing 16 changed files with 178 additions and 98 deletions.
7 changes: 7 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,12 @@ post_install do |installer|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
# dart: PermissionGroup.notification
'PERMISSION_NOTIFICATIONS=1',
]
end
end
end
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ SPEC CHECKSUMS:
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a

PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189


COCOAPODS: 1.12.1
12 changes: 6 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 20055;
CURRENT_PROJECT_VERSION = 20057;
DEVELOPMENT_TEAM = JLKV36C38P;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.55;
MARKETING_VERSION = 2.0.57;
PRODUCT_BUNDLE_IDENTIFIER = org.meditofoundation;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down Expand Up @@ -662,15 +662,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 20055;
CURRENT_PROJECT_VERSION = 20057;
DEVELOPMENT_TEAM = JLKV36C38P;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.55;
MARKETING_VERSION = 2.0.57;
PRODUCT_BUNDLE_IDENTIFIER = org.meditofoundation;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand All @@ -691,15 +691,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 20055;
CURRENT_PROJECT_VERSION = 20057;
DEVELOPMENT_TEAM = JLKV36C38P;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.55;
MARKETING_VERSION = 2.0.57;
PRODUCT_BUNDLE_IDENTIFIER = org.meditofoundation;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down
1 change: 1 addition & 0 deletions lib/constants/strings/string_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class StringConstants {
'Allow notifications for gentle meditation reminders and updates on fresh content and new features.';
static const String allowNotifications = 'Allow notifications';
static const String notNow = 'Not now';
static const String bugReport = 'Bug report';
static const String debugInfo = '--- Debug info ---';
static const String writeBelowThisLine = '--- Write below this line ---';

Expand Down
1 change: 1 addition & 0 deletions lib/constants/types/type_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class TypeConstants {
static const String LINK = 'link';
static const String FOLDER = 'folder';
static const String MEDITATION = 'meditation';
static const String EMAIL = 'email';
}

class EventTypes {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:Medito/constants/constants.dart';
import 'package:Medito/models/models.dart';
import 'package:Medito/providers/providers.dart';
import 'package:Medito/repositories/repositories.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'device_and_app_info_provider.g.dart';
Expand All @@ -10,3 +12,33 @@ Future<DeviceAndAppInfoModel> deviceAndAppInfo(ref) {

return info.getDeviceAndAppInfo();
}

final deviceAppAndUserInfoProvider =
FutureProvider.autoDispose<String>((ref) async {
var me = await ref.watch(meProvider.future);
var deviceInfo = await ref.watch(deviceAndAppInfoProvider.future);

return _formatString(me, deviceInfo);
});

String _formatString(
MeModel? me,
DeviceAndAppInfoModel? deviceInfo,
) {
var id = StringConstants.id + ': ${me?.id ?? ''}';
var email = StringConstants.email + ': ${me?.email ?? ''}';
var appVersion =
'${StringConstants.appVersion}: ${deviceInfo?.appVersion ?? ''}';
var deviceModel =
'${StringConstants.deviceModel}: ${deviceInfo?.model ?? ''}';
var deviceOs = '${StringConstants.deviceOs}: ${deviceInfo?.os ?? ''}';
var devicePlatform =
'${StringConstants.devicePlatform}: ${deviceInfo?.platform ?? ''}';
var buidNumber =
'${StringConstants.buidNumber}: ${deviceInfo?.buildNumber ?? ''}';

var formattedString =
'$id\n$email\n$appVersion\n$deviceModel\n$deviceOs\n$devicePlatform\n$buidNumber';

return formattedString;
}
2 changes: 1 addition & 1 deletion lib/root_page_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _RootPageViewState extends ConsumerState<RootPageView> {
ref.read(audioPlayerNotifierProvider).initAudioHandler();
ref.read(remoteStatsProvider);
ref.read(postLocalStatsProvider);
ref.read(meProvider);
ref.read(deviceAppAndUserInfoProvider);
ref.read(pageviewNotifierProvider).addListenerToPage();
_saveFcmTokenEvent(ref);
ref
Expand Down
36 changes: 25 additions & 11 deletions lib/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ Future<bool> launchUrlMedito(String? href) async {
}

if (href != null && href.startsWith('mailto')) {
_launchEmailSubmission(href);
var version = await getDeviceInfoString();
var userId = prefs.getString(USER_ID);
var info =
'--- Please write email below this line $version, id:$userId ----';

await launchEmailSubmission(href, body: info);

return true;
} else if (href != null) {
final params = Uri(
path: href.replaceAll('mailto:', ''),
Expand All @@ -101,23 +108,30 @@ Future<bool> launchUrlMedito(String? href) async {
return true;
}

void _launchEmailSubmission(String href) async {
var version = await getDeviceInfoString();

var prefs = await SharedPreferences.getInstance();
var userId = prefs.getString(USER_ID);
var info = '--- Please write email below this line $version, id:$userId ----';
Future<void> launchEmailSubmission(
String href, {
String? subject,
String? body,
}) async {
var query = '';
if (subject != null) {
query = 'subject=$subject';
}
if (body != null) {
var _body = body.replaceAll('\n', '\r\n');
query = query != '' ? '$query&body=$_body' : 'body=$_body';
}

final params = Uri(
scheme: 'mailto',
path: href.replaceAll('mailto:', ''),
query: 'body=$info',
query: query,
);

var url = params.toString();
if (await canLaunchUrl(params)) {
await launchUrlMedito(url);
await launchUrl(params);
} else {
var url = params.toString();
print('Could not launch $url');
}
}
Expand Down Expand Up @@ -159,7 +173,7 @@ Future<File?> capturePng(BuildContext context, GlobalKey globalKey) async {

final directory = await getTemporaryDirectory();
final file = File('${directory.path}/stats.png');

return await file.writeAsBytes(exportedPng);
}

Expand Down
7 changes: 6 additions & 1 deletion lib/views/auth/join_verify_OTP_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ class _JoinVerifyOTPViewState extends ConsumerState<JoinVerifyOTPView> {
if (status == Status.COMPLETED) {
await removeFirebaseToken();
await requestGenerateFirebaseToken();
// ignore: unused_result
ref.invalidate(meProvider);
ref.read(meProvider);
var params = JoinRouteParamsModel(
screen: widget.fromScreen, email: widget.email);
screen: widget.fromScreen,
email: widget.email,
);
unawaited(context.push(
RouteConstants.joinWelcomePath,
extra: params,
Expand Down
26 changes: 19 additions & 7 deletions lib/views/folder/folder_view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:Medito/widgets/widgets.dart';
import 'package:Medito/constants/constants.dart';
import 'package:Medito/models/models.dart';
Expand Down Expand Up @@ -164,29 +166,39 @@ class _FolderViewState extends ConsumerState<FolderView>
String? path,
BuildContext context,
) {
checkConnectivity().then((value) {
checkConnectivity().then((value) async {
if (value) {
var location = GoRouter.of(context).location;
if (type == TypeConstants.FOLDER) {
if (location.contains('folder2')) {
context.push(getPathFromString(
unawaited(context.push(getPathFromString(
RouteConstants.folder3Path,
[location.split('/')[2], widget.id, id.toString()],
));
)));
} else {
context.push(getPathFromString(
unawaited(context.push(getPathFromString(
RouteConstants.folder2Path,
[widget.id, id.toString()],
));
)));
}
} else if (type == TypeConstants.EMAIL) {
var deviceAppAndUserInfo =
await ref.read(deviceAppAndUserInfoProvider.future);
var _info =
'${StringConstants.debugInfo}\n$deviceAppAndUserInfo\n${StringConstants.writeBelowThisLine}';

await launchEmailSubmission(
path.toString(),
body: _info,
);
} else {
context.push(
unawaited(context.push(
getPathFromString(
type,
[id.toString()],
),
extra: {'url': path ?? ''},
);
));
}
} else {
createSnackBar(StringConstants.checkConnection, context);
Expand Down
29 changes: 21 additions & 8 deletions lib/views/home/widgets/announcement/announcement_widget.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:Medito/constants/constants.dart';
import 'package:Medito/models/models.dart';
import 'package:Medito/providers/providers.dart';
Expand Down Expand Up @@ -141,15 +143,26 @@ class _AnnouncementWidgetState extends ConsumerState<AnnouncementWidget> {
BuildContext context,
WidgetRef ref,
AnnouncementModel element,
) {
) async {
_handleTrackEvent(ref, element.id, element.ctaTitle);
context.push(
getPathFromString(
element.ctaType,
[element.ctaPath.toString().getIdFromPath()],
),
extra: {'url': element.ctaPath},
);
if (element.ctaType == TypeConstants.EMAIL) {
var deviceAppAndUserInfo =
await ref.read(deviceAppAndUserInfoProvider.future);
var _info =
'${StringConstants.debugInfo}\n$deviceAppAndUserInfo\n${StringConstants.writeBelowThisLine}';
await launchEmailSubmission(
element.ctaPath.toString(),
body: _info,
);
} else {
unawaited(context.push(
getPathFromString(
element.ctaType,
[element.ctaPath.toString().getIdFromPath()],
),
extra: {'url': element.ctaPath},
));
}
}

void _handleTrackEvent(
Expand Down
Loading

0 comments on commit e2165d0

Please sign in to comment.