Pouchdb changes feed when hybrid app is paused - ionic-framework

i have question. Is it possible to keep changes feed alive when hybrid app is in background or closed?
var changes = db.changes({
since: 'now',
live: true,
include_docs: true,
timeout: false
// attachments: true
}).on('change', function (change) {
onChange(change);
// handle change
}).on('complete', function (info) {
// changes() was canceled
}).on('error', function (err) {
console.log(JSON.stringify(err))
});

No. The only way this could work is with Service Worker and Background Sync. It seems there's a polyfill for iOS: https://github.com/MobileChromeApps/cordova-plugin-service-worker-background-sync

Related

Error: No named parameter with the name 'onSelectNotification'

class HelperNotification {
static Future<void> initialize(FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin) async {
var androidInitialize = new AndroidInitializationSettings('notification_icon');
var iOSInitialize = new DarwinInitializationSettings();
var initializationsSettings = new InitializationSettings(android: androidInitialize, iOS: iOSInitialize);
flutterLocalNotificationsPlugin.initialize(initializationsSettings, onSelectNotification:(String? payload) async {
try{
if(payload != null && payload.isNotEmpty) {
// Get.toNamed(RouteHelper.getOrderDetailsRoute(int.parse(payload)));
}else {
// Get.toNamed(RouteHelper.getNotificationRoute());
}
}catch (e) {}
return;
});
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
);
I Found that there was an update with the local notification package but i was trying to impliment it and was unsuccessful can you help me figure it out?
Since version 10.0.0 of the flutter_local_notifications plugin, they removed onSelectNotification parameter. You can read more about it in their changelog:
Breaking change
callbacks have now been reworked. There are now the
following callbacks and both will pass an instance of the
NotificationResponse class onDidReceiveNotificationResponse: invoked
only when the app is running. This works for when a user has selected
a notification or notification action. This replaces the
onSelectNotification callback that existed before. For notification
actions, the action needs to be configured to indicate the the app or
user interface should be shown on invoking the action for this
callback to be invoked i.e. by specifying the
DarwinNotificationActionOption.foreground option on iOS and the
showsUserInterface property on Android. On macOS and Linux, as there's
no support for background isolates it will always invoke this callback
onDidReceiveBackgroundNotificationResponse: invoked on a background
isolate for when a user has selected a notification action. This
replaces the onSelectNotificationAction callback
Read more here: https://pub.dev/packages/flutter_local_notifications/changelog

Why does Pusher update the UI only after navigating to another tab?

I used pusher to add real-time updates to my web app. Like if a user hits the like button on a post, the number of likes increases instantaneously in the UI.
That works fine when I run the app locally (illustrative GIF).
But when I deployed the app to Vercel, Pusher doesn't update the UI, unless I navigate to another tab and then return back to my app tab (GIF).
Vercel logs show that everything works as expected. The React component subscribes properly to Pusher channel and gets the new data. However, the UI never updates while I'm viewing the tab.
// Setting up pusher
import Pusher from "pusher";
const pusher = new Pusher({
appId: PUSHER_APP_ID,
key: PUSHER_KEY,
secret: PUSHER_SECRET,
cluster: us2,
useTLS: false,
});
export default pusher;
// Subscribing the component to Pusher channel
useEffect(
function subscribeToPusher() {
const pusher = new Pusher(PUSHER_KEY, {
cluster: us2,
forceTLS: true,
});
const channel = pusher.subscribe("reviews");
channel.bind("updated", updateReview);
},
[]
);
// Listen to MongoDB's ChangeStream
changeStream.on("change", async (change) => {
console.log("change: ", change);
switch (change.operationType) {
case "update": {
const document = change.fullDocument;
pusher.trigger(collectionName, "updated", document);
break;
}
}
});
Note: the deployed version works as expected when I run npm run dev locally which is a bit strange.
It was Vercel. It worked once I tried Heroku.

Run action before Ionic Vue closes or app runs in background

How can i detect in Ionic Vue if the app closes or if the app is send to the background?
this.platformor platform isn't available or does not work?!
You can subscribe to the appStateChange event, like described here: https://capacitorjs.com/docs/apis/app
Example:
import { App } from '#capacitor/app'
export default {
created () {
App.addListener('appStateChange', state => {
if (!state.isActive) { // if isActive is true, App got sent to foreground, if it is false, it got sent to the background
...
}
})
}
}

Flutter- How to know AudioService is stopped?

I am working with audio_service flutter package. I want to pop a player page if Audio Service stops. How to get the Audio Service stopped event? I didn't find any events to check if service is stopped
(Answer update: Since v0.18, the service is effectively always running while the app is running, so there is no longer a need to check. The following answer is for v0.17 and earlier.)
AudioService.running will emit true when the service is running and false when it is not.
To listen to when it changes from true to false, you could try this:
// Cast runningStream from dynamic to the correct type.
final runningStream =
AudioService.runningStream as ValueStream<bool>;
// Listen to stream pairwise and observe when it becomes false
runningStream.pairwise().listen((pair) {
final wasRunning = pair.first;
final isRunning = pair.last;
if (wasRunning && !isRunning) {
// take action
}
});
If you instead want to listen to the stopped playback state, you need to ensure that your background audio task actually emits that state change in onStop:
#override
Future<void> onStop() async {
await _player.dispose();
// the "await" is important
await AudioServiceBackground.setState(
processingState: AudioProcessingState.stopped);
// Shut down this task
await super.onStop();
}
This way, you can listen for this state in the UI:
AudioService.playbackStateStream.listen((state) {
if (state.processingState == AudioProcessingState.stopped)) {
// take action
}
});

Vidyo Web using Javascript - How to render local camera to more than one view?

I tried calling AssignViewToLocalCamera with different view Ids in which the first first invoke is working and the subsequent calls are not.
//working
_vidyoConnector.AssignViewToLocalCamera({
viewId: "div1",
localCamera: _localCamera,
displayCropped: false,
allowZoom: false
});
// not working
vidyoConnector.AssignViewToLocalCamera({
viewId: "div2",
localCamera: _localCamera,
displayCropped: false,
allowZoom: false
})
// not working
vidyoConnector.AssignViewToLocalCamera({
viewId: "div3",
localCamera: _localCamera,
displayCropped: false,
allowZoom: false
})
Please show some light here.
Thanks in Advance.
Rendering the same video stream to multiple renderer div is not supported by vidyo.io.