@ -1,3 +1,5 @@
import ' dart:async ' ;
import ' package:diplomaticquarterapp/config/config.dart ' ;
import ' package:diplomaticquarterapp/config/shared_pref_kay.dart ' ;
import ' package:diplomaticquarterapp/core/model/ImagesInfo.dart ' ;
@ -19,9 +21,9 @@ import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service
import ' package:diplomaticquarterapp/services/family_files/family_files_provider.dart ' as family ;
import ' package:diplomaticquarterapp/services/robo_search/event_provider.dart ' ;
import ' package:diplomaticquarterapp/theme/colors.dart ' ;
import ' package:diplomaticquarterapp/uitl/HMGNetworkConnectivity.dart ' ;
import ' package:diplomaticquarterapp/uitl/LocalNotification.dart ' ;
import ' package:diplomaticquarterapp/uitl/SignalRUtil.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_shared_preferences.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_toast.dart ' ;
import ' package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart ' ;
import ' package:diplomaticquarterapp/uitl/location_util.dart ' ;
@ -35,12 +37,13 @@ import 'package:diplomaticquarterapp/widgets/others/not_auh_page.dart';
import ' package:firebase_messaging/firebase_messaging.dart ' ;
import ' package:flutter/cupertino.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:flutter_app_icon_badge/flutter_app_icon_badge.dart ' ;
import ' package:flutter_ios_voip_kit/call_state_type.dart ' ;
import ' package:flutter_ios_voip_kit/flutter_ios_voip_kit.dart ' ;
import ' package:flutter_local_notifications/flutter_local_notifications.dart ' ;
import ' package:flutter_svg/flutter_svg.dart ' ;
import ' package:permission_handler/permission_handler.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:flutter_app_icon_badge/flutter_app_icon_badge.dart ' ;
import ' ../../locator.dart ' ;
import ' ../../routes.dart ' ;
@ -91,6 +94,35 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
var event = RobotProvider ( ) ;
var familyFileProvider = family . FamilyFilesProvider ( ) ;
/ / VoIPKit
final voIPKit = FlutterIOSVoIPKit . instance ;
var dummyCallId = ' 123456 ' ;
var dummyCallerName = ' Dummy Tester ' ;
Timer timeOutTimer ;
bool isTalking = false ;
var sharedPref = new AppSharedPreferences ( ) ;
var data = {
" AppointmentNo " : " 2016059247 " ,
" ProjectID " : " 15 " ,
" NotificationType " : " 10 " ,
" background " : " 0 " ,
" doctorname " : " Call from postman " ,
" clinicname " : " LIVECARE FAMILY MEDICINE AND GP " ,
" speciality " : " General Practioner " ,
" appointmentdate " : " 2022-01-19 " ,
" appointmenttime " : " 12:10 " ,
" PatientName " : " Testing " ,
" session_id " : " 1_MX40NjIwOTk2Mn5-MTY0NzI1NjYxNDI2OX5ySXhlVjZjam13RFdMVmdleWVsSDhzQkx-fg " ,
" token " :
" T1==cGFydG5lcl9pZD00NjIwOTk2MiZzaWc9OGMyY2IyYWFiZmZmMzI4ZmEwMjgxNDdmMGFhZGI0N2JiZjdmZWY4MjpzZXNzaW9uX2lkPTFfTVg0ME5qSXdPVGsyTW41LU1UWTBOekkxTmpZeE5ESTJPWDV5U1hobFZqWmphbTEzUkZkTVZtZGxlV1ZzU0RoelFreC1mZyZjcmVhdGVfdGltZT0xNjQ3MjU2NjE0Jm5vbmNlPTAuMjgzNDgyNjM1NDczNjQ2OCZyb2xlPW1vZGVyYXRvciZleHBpcmVfdGltZT0xNjQ3MjU4NDE0JmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9 " ,
" DoctorImageURL " : " https://image.shutterstock.com/image-vector/sample-stamp-square-grunge-sign-260nw-1474408826.jpg " ,
" callerID " : " 9920 " ,
" PatientID " : " 1231755 " ,
" is_call " : " true "
} ;
void _requestIOSPermissions ( ) {
flutterLocalNotificationsPlugin . resolvePlatformSpecificImplementation < IOSFlutterLocalNotificationsPlugin > ( ) ? . requestPermissions (
alert: true ,
@ -99,6 +131,24 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
) ;
}
void _showRequestAuthLocalNotification ( ) async {
await voIPKit . requestAuthLocalNotification ( ) ;
}
void _timeOut ( {
int seconds = 15 ,
} ) async {
timeOutTimer = Timer ( Duration ( seconds: seconds ) , ( ) async {
print ( ' 🎈 example: timeOut ' ) ;
final incomingCallerName = await voIPKit . getIncomingCallerName ( ) ;
voIPKit . unansweredIncomingCall (
skipLocalNotification: false ,
missedCallTitle: ' 📞 Missed call ' ,
missedCallBody: ' There was a call from $ incomingCallerName ' ,
) ;
} ) ;
}
bool isPageNavigated = false ;
LocationUtils locationUtils ;
@ -232,6 +282,74 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
void initState ( ) {
super . initState ( ) ;
PushNotificationHandler . getInstance ( ) . onResume ( ) ;
/ / VoIP Callbacks
/ / voIPKit . getVoIPToken ( ) . then ( ( value ) {
/ / print ( ' 🎈 example: getVoIPToken: $ value ' ) ;
/ / sharedPref . setString ( " VOIPToken " , value ) ;
/ / } ) ;
/ /
/ / voIPKit . onDidReceiveIncomingPush = (
/ / Map < String , dynamic > payload ,
/ / ) async {
/ / print ( ' 🎈 example: onDidReceiveIncomingPush $ payload ' ) ;
/ / _timeOut ( ) ;
/ / } ;
/ /
/ / voIPKit . onDidRejectIncomingCall = (
/ / String uuid ,
/ / String callerId ,
/ / ) {
/ / if ( isTalking ) {
/ / return ;
/ / }
/ /
/ / print ( ' 🎈 example: onDidRejectIncomingCall $ uuid , $ callerId ' ) ;
/ / voIPKit . endCall ( ) ;
/ / timeOutTimer ? . cancel ( ) ;
/ /
/ / setState ( ( ) {
/ / isTalking = false ;
/ / } ) ;
/ / } ;
/ /
/ / voIPKit . onDidAcceptIncomingCall = (
/ / String uuid ,
/ / String callerId ,
/ / ) {
/ / / / print ( ' 🎈 example: isTalking $ isTalking ' ) ;
/ / / / if ( isTalking ) {
/ / / / return ;
/ / / / }
/ /
/ / print ( ' 🎈 example: onDidAcceptIncomingCall $ uuid , $ callerId ' ) ;
/ /
/ / var sessionID ;
/ / var token ;
/ /
/ / / / String sessionID = callerId . split ( " * " ) [ 0 ] ;
/ / / / String identity = callerId . split ( " * " ) [ 1 ] ;
/ / / / String name = callerId . split ( " * " ) [ 2 ] ;
/ / / /
/ / / / print ( " 🎈 SessionID: $ sessionID " ) ;
/ / / / print ( " 🎈 Identity: $ identity " ) ;
/ / / / print ( " 🎈 Name: $ name " ) ;
/ /
/ / voIPKit . acceptIncomingCall ( callerState: CallStateType . calling ) ;
/ / voIPKit . callConnected ( ) ;
/ / timeOutTimer ? . cancel ( ) ;
/ /
/ / print ( " 🎈 CALL ACCEPTED!!! " ) ;
/ / / / print ( " 🎈 Identity: $ identity " ) ;
/ / / / print ( " 🎈 Name: $ name " ) ;
/ /
/ / setState ( ( ) {
/ / isTalking = true ;
/ / } ) ;
/ / } ;
/ /
/ / _showRequestAuthLocalNotification ( ) ;
WidgetsBinding . instance . addObserver ( this ) ;
AppGlobal . context = context ;
@ -250,7 +368,7 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
/ / HMG ( Guest / Internet ) Wifi Access [ Zohaib Kambrani ]
/ / for now commented to reduce this call will enable it when needed
HMGNetworkConnectivity ( context ) . start ( ) ;
/ / HMGNetworkConnectivity ( context ) . start ( ) ;
_firebaseMessaging . getToken ( ) . then ( ( String token ) {
print ( " Firebase Token: " + token ) ;