-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle Late Notifications as missed calls
- Loading branch information
1 parent
8ed14b9
commit fbc084b
Showing
7 changed files
with
118 additions
and
7 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"sourceFile": "lib/service/notification_service.dart", | ||
"activeCommit": 0, | ||
"commits": [ | ||
{ | ||
"activePatchIndex": 0, | ||
"patches": [ | ||
{ | ||
"date": 1731272573644, | ||
"content": "Index: \n===================================================================\n--- \n+++ \n" | ||
} | ||
], | ||
"date": 1731272573644, | ||
"name": "Commit-0", | ||
"content": "import 'dart:convert';\nimport 'package:firebase_messaging/firebase_messaging.dart';\nimport 'package:flutter/foundation.dart';\nimport 'package:flutter_callkit_incoming/entities/android_params.dart';\nimport 'package:flutter_callkit_incoming/entities/call_kit_params.dart';\nimport 'package:flutter_callkit_incoming/entities/ios_params.dart';\nimport 'package:flutter_callkit_incoming/entities/notification_params.dart';\nimport 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart';\nimport 'package:uuid/uuid.dart';\nimport 'package:logger/logger.dart';\nimport 'package:telnyx_webrtc/model/push_notification.dart';\n\n\nclass NotificationService {\n\n static Future showNotification(RemoteMessage message) async {\n var logger = Logger();\n print('Received Incoming NotificationService!');\n logger.i('Received Incoming NotificationService! from background');\n var metadata = PushMetaData.fromJson(jsonDecode(message.data[\"metadata\"]));\n var received = message.data[\"message\"];\n var currentUuid = const Uuid().v4();\n\n\n CallKitParams callKitParams = CallKitParams(\n id: currentUuid,\n nameCaller: metadata.caller_name,\n appName: 'Telnyx Flutter Voice',\n avatar: 'https://i.pravatar.cc/100',\n handle: metadata.caller_number,\n type: 0,\n textAccept: 'Accept',\n textDecline: 'Decline',\n missedCallNotification: const NotificationParams(\n showNotification: true,\n isShowCallback: true,\n subtitle: 'Missed call',\n callbackText: 'Call back',\n ),\n duration: 30000,\n extra: message.data,\n headers: <String, dynamic>{'platform': 'flutter'},\n android: const AndroidParams(\n isCustomNotification: true,\n isShowLogo: false,\n ringtonePath: 'system_ringtone_default',\n backgroundColor: '#0955fa',\n backgroundUrl: 'https://i.pravatar.cc/500',\n actionColor: '#4CAF50',\n textColor: '#ffffff',\n incomingCallNotificationChannelName: \"Incoming Call\",\n missedCallNotificationChannelName: \"Missed Call\"),\n ios: const IOSParams(\n iconName: 'CallKitLogo',\n handleType: 'generic',\n supportsVideo: true,\n maximumCallGroups: 2,\n maximumCallsPerCallGroup: 1,\n audioSessionMode: 'default',\n audioSessionActive: true,\n audioSessionPreferredSampleRate: 44100.0,\n audioSessionPreferredIOBufferDuration: 0.005,\n supportsDTMF: true,\n supportsHolding: true,\n supportsGrouping: false,\n supportsUngrouping: false,\n ringtonePath: 'system_ringtone_default',\n ),\n );\n\n\n await FlutterCallkitIncoming.showCallkitIncoming(callKitParams);\n }\n\n static Future showMissedCallNotification(RemoteMessage message) async {\n var logger = Logger();\n print('Received Incoming NotificationService!');\n logger.i('Received Incoming NotificationService! from background');\n var metadata = PushMetaData.fromJson(jsonDecode(message.data[\"metadata\"]));\n var received = message.data[\"message\"];\n var currentUuid = const Uuid().v4();\n\n\n CallKitParams callKitParams = CallKitParams(\n id: currentUuid,\n nameCaller: metadata.caller_name,\n appName: 'Telnyx Flutter Voice',\n avatar: 'https://i.pravatar.cc/100',\n handle: metadata.caller_number,\n type: 0,\n textAccept: 'Accept',\n textDecline: 'Decline',\n missedCallNotification: const NotificationParams(\n showNotification: true,\n isShowCallback: true,\n subtitle: 'Missed call',\n callbackText: 'Call back',\n ),\n duration: 30000,\n extra: message.data,\n headers: <String, dynamic>{'platform': 'flutter'},\n android: const AndroidParams(\n isCustomNotification: true,\n isShowLogo: false,\n ringtonePath: 'system_ringtone_default',\n backgroundColor: '#0955fa',\n backgroundUrl: 'https://i.pravatar.cc/500',\n actionColor: '#4CAF50',\n textColor: '#ffffff',\n incomingCallNotificationChannelName: \"Incoming Call\",\n missedCallNotificationChannelName: \"Missed Call\"),\n ios: const IOSParams(\n iconName: 'CallKitLogo',\n handleType: 'generic',\n supportsVideo: true,\n maximumCallGroups: 2,\n maximumCallsPerCallGroup: 1,\n audioSessionMode: 'default',\n audioSessionActive: true,\n audioSessionPreferredSampleRate: 44100.0,\n audioSessionPreferredIOBufferDuration: 0.005,\n supportsDTMF: true,\n supportsHolding: true,\n supportsGrouping: false,\n supportsUngrouping: false,\n ringtonePath: 'system_ringtone_default',\n ),\n );\n\n\n await FlutterCallkitIncoming.showMissCallNotification(callKitParams);\n }\n}\n" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters