This profile will expand the notification tray every time you unlock your screen, are holding your phone and have important notifications present.
This is how it'll look like in the end:
STEP 1 - TRIGGER ON UNLOCKED DISPLAY
- Create a new profile with the Display Unlocked event condition
- Create an entry task for the profile
STEP 2 - GET PHONE ROTATION
15 is the sensor of type TYPE_GAME_ROTATION_VECTOR. More info on it here. Basically, this will return 4 values. The first 3 values are angles in degrees related to the current rotation of your phone. We're interested in the second value that's returned which relates to the rotation in Y, which says if your phone's screen is pointed up, towards you or at the ground.
- Add an AutoTools Sensors action
- Set the Sensor Number to 15
This value will be approximately 90 if the phone is laying flat on a table and approximately 0 if the phone is in a vertical position. So we're interested in something in between. To give it a bit of margin, let's consider that while the device is being held the values will be between 0 and 70.
- Enable the Convert Orientation so that the values are converted to degrees
- Accept and add a Flash action with the value %atsensor2 which is the Y value we're looking for
STEP 3 - CHECK IF DEVICE IS BEING HELD
- Add an If action and make the conditions so that %atsensor2 is greater than 0 and less than 70.
- Add an End If action
STEP 4 - CHECKING IMPORTANT NOTIFICATIONS
%antitle() contains all the titles of the queried notifications. Using %antitle(#) returns the number of queried notifications. You could have used any other notification related variable to count them.
- Add an AutoNotification Query action
- Configure it so that it only gets non-persistent notifications from the apps you want. In this example I used the Join app.
- Go back to Tasker and add a Status Bar action
- Set it to Expanded only if %antitle(#) is greater than 0.
- Back out of Tasker to save
STEP 5 - TESTING
If you now clear any Join notifications, turn off your screen and turn it on again, nothing will happen regardless if you're holding the phone or not.
If you receive a Join notification and turn on the phone while it's flat on a table, nothing will happen either.
If you pick up your phone with the notification present the notification tray will automatically expand so you don't miss out on all the Join goodness