Skip to content

Commit

Permalink
Fix WebVersion does to support Platform.isAndroid
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacakakpo1 committed Sep 24, 2024
1 parent 69ff9fc commit 1d70646
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
32 changes: 18 additions & 14 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,20 +284,24 @@ class _MyAppState extends State<MyApp> {
});
}

if (Platform.isAndroid) {
// Handle Push when app comes from background :: Only for Android
TelnyxClient.getPushData().then((data) {
// whenever you open the app from the terminate state by clicking on Notification message,
if (data != null) {
handlePush(data);
print(
"getPushData : getInitialMessage :: Notification Message: $data");
} else {
print("getPushData : No data");
}
});
} else if (Platform.isIOS && !mainViewModel.callFromPush) {
logger.i("iOS :: connect");
try {
if (defaultTargetPlatform == TargetPlatform.android) {
// Handle Push when app comes from background :: Only for Android
TelnyxClient.getPushData().then((data) {
// whenever you open the app from the terminate state by clicking on Notification message,
if (data != null) {
handlePush(data);
print(
"getPushData : getInitialMessage :: Notification Message: $data");
} else {
print("getPushData : No data");
}
});
} else if (Platform.isIOS && !mainViewModel.callFromPush) {
logger.i("iOS :: connect");
}
} catch (e) {
print("Error: $e");
}
}

Expand Down
1 change: 0 additions & 1 deletion lib/view/screen/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver {
if (!kIsWeb) {
_checkPermissions();
}
logger.i("Version ${Platform.operatingSystemVersion}");

sipUserController.text = MOCK_USER;
sipPasswordController.text = MOCK_PASSWORD;
Expand Down
Empty file.
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ dependencies:
cupertino_icons: ^1.0.2
firebase_messaging: ^15.0.3
firebase_core: ^3.2.0
flutter_local_notifications: ^16.2.0
flutter_callkit_incoming: ^2.0.4+1
shared_preferences: ^2.2.3
permission_handler: ^11.3.1
Expand Down
6 changes: 3 additions & 3 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
var serviceWorkerVersion = null;
var flutter_service_worker_version = null;
var scriptLoaded = false;
function loadMainDartJs() {
if (scriptLoaded) {
Expand All @@ -56,7 +56,7 @@
// Wait for registration to finish before dropping the <script> tag.
// Otherwise, the browser will load the script multiple times,
// potentially different versions.
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + flutter_service_worker_version;
navigator.serviceWorker.register(serviceWorkerUrl)
.then((reg) => {
function waitForActivation(serviceWorker) {
Expand All @@ -71,7 +71,7 @@
// No active web worker and we have installed or are installing
// one for the first time. Simply wait for it to activate.
waitForActivation(reg.installing || reg.waiting);
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
} else if (!reg.active.scriptURL.endsWith(flutter_service_worker_version)) {
// When the app updates the serviceWorkerVersion changes, so we
// need to ask the service worker to update.
console.log('New service worker available.');
Expand Down

0 comments on commit 1d70646

Please sign in to comment.