ionic 2 - detect shake device when app in background mode - ionic2

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.

Related

How create alarm on SwiftUI watchOS

I want create alarm app for my apple watch but I don't know how to wake a person. There is an app - Sleep Cycle and they trigger something that looks like on picture:
Watch vibrates constantly like default timer app on apple watch. The question is what's the name of this interface element? This not a notification, not an Alert (https://developer.apple.com/documentation/swiftui/alert), not a WKInterfaceDevice play function. I just want reproduce that behavior. Thanks for help!
What you need is notifyUserWithHaptic, it gives a repeating haptic and also displays this notification style screen with Open and Stop buttons if the app isn't active.
As per Apple Docs
For schedulable sessions such as smart alarms, call this method during
the session to alert the user. When you call the method, the system
plays repeating haptic feedback. If the app isn’t active, the system
also displays a system alarm alert on the watch.
Link to Apple Documentation

Expo-notifications notification event don't work if app is not running in the background

Expo sdk: 40
responseListener.current =
    Notifications.addNotificationResponseReceivedListener((response) => {
      axios.post("https://<logUrl.onOurServer.com>", {
        test: "background",
      });
    });
addNotificationResponseReceivedListener // dont work when app's not running
This method sends me a notification mail when app is running but if the apps is not running, I can't capture this event from a cold start. Is there a permission or something for this to work?
I've just copy pasted the code from https://docs.expo.io/versions/latest/sdk/notifications/
and just added logging to a https endpoint, it does not work on cold start.

How to send a "you haven't used your app in a while " push notification in React Native using AWS?

Just wanted to know from a high level how I would accomplish this.
I thought that when a user opens the application, I will keep track of the last opened time in a Dynamo DB table.
Then I could have a background worker constantly check and see if anybody hasn't used their app in 3 or 4 days and then send a push notification, ie, "you haven't used your app in a while, why don't you open it up and do XYZ."
From a very high level, there are two possible ways:
1.) Local notifications (you don't need AWS for this):
You can schedule a local notification, every time the user opens up the app (or better - every time the user brings the app to foreground). It works like: User opens app -> cancel old scheduled notification if existing -> schedule new notification for "in 3 or 4 days" -> ready :-)
You can use something like this: https://github.com/zo0r/react-native-push-notification (see section Sheduled Notifications).
2.) You could do it with remote notifications (https://aws.amazon.com/sns/):
You can go the way you proposed. Then you have to store an entry in your db with the push notification token of the device and the last time the app was opened. Your worker then has to check and send the push message to the device using a service like SNS.
I would recommend 1.) over 2.) because you are independent from the users internet connection when getting the app opening info. In 2.) you can miss the opening info, when the user opens the app without internet connection. Also 2.) is more expensive then 1.) when you scale your app.
An advantage of 2.) would be, that you are more flexible when and what you send in your notification, since you can edit it on server side. 1.) would mean that it is coded in your app (at least until you build a synchronization mechanism for the variables) :-)

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

Google Glass Timeline notifications for In built actions and custom actions are not working after updation(of XE-16 glass update)

We have developed a google glass ware(timeline based) app. In that first we will send some timeline cards to the glass with some inbuilt menu items and custom menu items.
and we have configured the proxy url for getting notifications for time line.
It worked fine for so many days.
But After Google Glass XE-16 update we are not getting the timeline notifications
Can you please guide us inresolving the issue.
Hi Prisoner,
for inserting timeline we have used the following code:
global $base_url="http:\/\/mysite.com\/mirror";
$client = get_google_api_client();
$client->setAccessToken(get_credentials($_SESSION['userid'])); // A glass service for interacting with the Mirror API
$mirror_service = new Google_MirrorService($client);
$new_timeline_item = new Google_TimelineItem();
$new_timeline_item->setText('Hey I am testing new');
$notification = new Google_NotificationConfig();
$notification->setLevel("DEFAULT");
$new_timeline_item->setNotification($notification);
$menu_items = array();
$custom_menu_item = new Google_MenuItem();
$custom_menu_value = new Google_MenuValue();
$custom_menu_value->setDisplayName("Add Item");
$custom_menu_value->setIconUrl( $base_url . "/static/images/tulip.jpg");
$custom_menu_item->setValues(array($custom_menu_value));
$custom_menu_item->setAction("CUSTOM");
$custom_menu_item->setId("add_to_cart_item"); // This is how you identify it on the notification ping
array_push($menu_items, $custom_menu_item);
$new_timeline_item->setMenuItems($menu_items);
insert_timeline_item($mirror_service, $new_timeline_item, "image/jpeg", file_get_contents($base_url . "/static/images/tulip.jpg"));
for this we are trying to add new custom menus and built in menus like (pin,delete,share,send)
To subscribe to notifications we have used the Google glass Php mirror api function.
subscribe_to_notifications($mirror_service, "timeline", $_SESSION['userid'], $base_url . "/notify.php");
All these are working fine before XE-16 version update. After updation we are not able to get notification for time line card notifications
This is a known issue with sending image attachments. See details here:
https://code.google.com/p/google-glass-api/issues/detail?id=491
So the part of your code that has to change is:
insert_timeline_item($mirror_service, $new_timeline_item, "image/jpeg", file_get_contents($base_url . "/static/images/tulip.jpg"));
Needs to change to:
insert_timeline_item($mirror_service, $new_timeline_item, null, null);
And use setHTML instead of setText and include an img element with a src tag that points to a web URL. E.g.:
<img src="http://example.com/static/images/tulip.jpg" />
Note that you also have to factory reset your Glass. You can tell if you have the problem by trying to run a menu command and the spinning double arrow in the bottom right corner gets stuck and an a crash stack trace is visible on ADB logcat output on the Glass. So to fix the problem, first you have to not use image attachments, and second you have to reset the Glass to fix the broken timeline sync on the Glass.