Handle up/down buttons of Chromecast Voice Remote on Chromecast receiver side - casting

I'm casting from iOS/Android to Google Chromecast device and trying to switch channels by clicking up/down buttons, but can not catch an event if Up or Down button has been clicked.
Tried to listen for all events from cast.framework.events.EventType.ALL but I receive only final events like (PLAY, PAUSE, TIME_UPDATE, etc.)
const context = cast.framework.CastReceiverContext.getInstance();
const playerManager = context?.getPlayerManager();
playerManager?.addEventListener(cast.framework.events.EventType.ALL, (event) => {
logScreen.info(`event: ${event.type}`);
});
Maybe somebody knows how to catch an event/message that up/down button called on Chromecast Voice Remote?
Thanks

Related

How to change settings to receive Notifications in background state from within Expo app?

I am receiving push notifications via expo-notification. I created a button within the app that allows you to set whether or not to receive notifications.
This app is made to not receive notifications while in the foreground state. I would like to implement a notification so that when that button is in the ON state, notifications can be received in the Background state, and in the OFF state, notifications cannot be received in the Background state.
const BACKGROUND_NOTIFICATION_TASK = "BACKGROUND-NOTIFICATION-TASK";
TaskManager.defineTask(BACKGROUND_NOTIFICATION_TASK, ({ data, error, executionInfo }) => {
if (error) {
console.log("error occurred");
}
if (data) {
console.log("data-----", data);
}
});
Notifications.registerTaskAsync(BACKGROUND_NOTIFICATION_TASK);
The above function is a function set for background reception.
I tried unregisterTaskAsync when the button is in OFF state and I still receive the notification in the background. What method should I use to implement changing notification settings in-app?

Livewire loading state disappers if leaving the tab or window

I use Livewire loading state to show Processing message on submit event. The loading message disappered when I click on other browser tab or window while the task at server-side still running.
Is there anyway to keep loading message still show untill the the task finished?

Swift 3: how to enable local notification and disable push notification in foreground

I am using both local and push notification in my app and i receive notification for both in background and foreground but i just want to receive only local notification in foreground.
You must threat application state in didReceiveRemoteNotification
and use UIApplicationState (can be .active in Swift or UIApplicationStateActive in Objective-C for example) see documentation apple docs

How to intercept AWS SNS messages to iOs mobile endpoints in Xamarin?

The documentation on AWS -SNS for use of SNS within Xamarin iOS projects shows how to register an iOS device to receive messages from SNS, but not clear how to intercept those messages within the application and programtically respond to the message. How do I capture the incoming message, and process appropriately rather than just showing the text of the message received? Is this done by sending a different message than is shown in the AWS console, and where can I intercept it in my application?
This is the example I've been following:
public override bool FinishedLaunching(UIApplication app, NSDictionary options) {
// do something
var pushSettings = UIUserNotificationSettings.GetSettingsForTypes (
UIUserNotificationType.Alert |
UIUserNotificationType.Badge |
UIUserNotificationType.Sound,
null
);
app.RegisterUserNotifications(pushSettings);
app.RegisterForRemoteNotifications();
// do something
return true;
}
public override void RegisteredForRemoteNotifications(UIApplication application, NSData token) {
var deviceToken = token.Description.Replace("<", "").Replace(">", "").Replace(" ", "");
if (!string.IsNullOrEmpty(deviceToken)) {
//register with SNS to create an endpoint ARN
var response = await SnsClient.CreatePlatformEndpointAsync(
new CreatePlatformEndpointRequest {
Token = deviceToken,
PlatformApplicationArn = "YourPlatformArn" /* insert your platform application ARN here */
});
}
}
Here is the message I'm sending:
{
"APNS_SANDBOX":"{\"aps\":{\"alert\":\"This is my message\"}}"
}
This seems to work fine for displaying a text message sent from the AWS console, whether the app is running or not, but that's not what I need for my app. (e.g. a chess app, where the SNS messages are used to exchange moves made by a pair of users and the app displays them.)
The FinishedLaunching method contains several not altogether helpful "do something" , but I can't figure out how to, say call some method in my PCL when a particular message is received and pass the content of the message to that method.
You can subscribe the DidReceiveRemoteNotification() event in AppDelegate.cs to get your content you sent on SNS.
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
// retrieve something from a server somewhere
}
This event will trigger when user taps the notification to open the app and when this app is on background state or foreground state.
If this app is closed this event will not trigger, but we can also get the content in public override bool FinishedLaunching(UIApplication app, NSDictionary options) with the parameter options.
Moreover if you want to get it in PCL, we can make a MessagingCenter to achieve this:
Send content on native platform:
MessagingCenter.Send<object, NSDictionary>(this, "Notification", userInfo);
Then receive this MessagingCenter on PCL somewhere you like:
MessagingCenter.Subscribe<object, NSDictionary>(this, "Notification", (sender, dic) =>
{
});

ionic 2 - detect shake device when app in background mode

I want create application with ionic 2 that it send sms when user shaked mobile and so my app must be in background mode
I search and find this plugin for set app to background
https://github.com/katzer/cordova-plugin-background-mode
but how detect shake device when use this plugin ?
I have never worked with the background-plugin, but if it lets you run the app indefinitely in the background, you should be able to use the shake plugin to detect shakes: https://ionicframework.com/docs/native/shake/
Try to add
const watch = this.shake.startWatch(60).subscribe(() => {
// do something
});
to your app.component.ts and see if it works.