Android Push Notification - Vibration

I’ve got remote push notifications working for Android but I don’t get a vibration when the notification is received on the device.  I’m testing on a Samsung Galaxy II running Android 2.3.6.  Is this a bug?  I get the same behavior from the sample app as well.

Thanks.

Do you have the vibrate permission on?

   androidPermissions =
   {
       “android.permission.VIBRATE”,
       “android.permission.INTERNET”
   },

in your build.settings?

Thanks for the reply Rob.  My build.settings file has the following for android and vibrate does not appear to be working.  Ditto for the sample application currently using build 1154.

    android =     {         versionCode = "1",         permissions =         {             { name = ".permission.C2D\_MESSAGE", protectionLevel = "signature" },         },         usesPermissions =         {             "android.permission.INTERNET",             "android.permission.GET\_ACCOUNTS",             "android.permission.RECEIVE\_BOOT\_COMPLETED",             "com.google.android.c2dm.permission.RECEIVE",             ".permission.C2D\_MESSAGE",             "android.permission.VIBRATE"         },     },  

Do you have the vibrate permission on?

   androidPermissions =
   {
       “android.permission.VIBRATE”,
       “android.permission.INTERNET”
   },

in your build.settings?

Thanks for the reply Rob.  My build.settings file has the following for android and vibrate does not appear to be working.  Ditto for the sample application currently using build 1154.

    android =     {         versionCode = "1",         permissions =         {             { name = ".permission.C2D\_MESSAGE", protectionLevel = "signature" },         },         usesPermissions =         {             "android.permission.INTERNET",             "android.permission.GET\_ACCOUNTS",             "android.permission.RECEIVE\_BOOT\_COMPLETED",             "com.google.android.c2dm.permission.RECEIVE",             ".permission.C2D\_MESSAGE",             "android.permission.VIBRATE"         },     },  

I havet the same problem. Sound works just fine. I have verified that my app has the vibrate permission from the app info dialog.

I am Starting to think that vibration isn’t supported? Is there anything special data you have to send in the push? I am using a custom push server if that matters.

Thanks!

If you call system.vibrate() does your device vibrate?

Rob

Same issue the system crush when It try to vibrate.

Here is the code:

local onButtonEvent = function (event )

system.vibrate()

end

This is my build.settings

– Supported values for orientation:

– portrait, portraitUpsideDown, landscapeLeft, landscapeRight

settings = {

orientation = {

default = “portrait”,

supported = { “portrait”, }

},

iphone = {

plist = {

UIStatusBarHidden = false,

UIPrerenderedIcon = true, – set to false for “shine” overlay

–UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend

            --[[

            – iOS app URL schemes:

            CFBundleURLTypes =

            {

                {

                    CFBundleURLSchemes =

                    {

                        “fbXXXXXXXXXXXXXX”, – example scheme for facebook

                        “coronasdkapp”, – example second scheme

                    }

                }

            }

            --]]

}

},

–[[

– Android permissions

       android =

    {

        versionCode = “1”,

        permissions =

        {

            { name = “.permission.C2D_MESSAGE”, protectionLevel = “signature” },

        },

        usesPermissions =

        {

            “android.permission.VIBRATE”

        },

    },    

]]–

}

I’ve tested some more and have found out that even doing a simple 

system.scheduleNotification(10)

won’t cause the device to vibrate in quiet mode, though it does make a sound if the sound is on.

A simple system.vibrate() call works just fine. This is my test app:

--This vibrate() function works as expected. local function vibrate() print("Vibrate") system.vibrate() end --This localNotification() function will make a noise if sound is on, but no vibration on quiet mode local function localNotification() print("Local notification") system.scheduleNotification(10) end local widget = require("widget") --Vibrate button widget.newButton {     left = display.screenOriginX + 30,     top = display.screenOriginY + 30,     fontSize = 60,     label = "Vibrate",     onRelease = vibrate } --Local notification button widget.newButton {     left = display.screenOriginX + 30,     top = display.screenOriginY + 130,     fontSize = 60,     label = "Local Notification",     onRelease = localNotification }

Have I missed something? Thanks!

Edit: I realize that after researching a bit more the “network” forum isn’t the best fit. I don’t know how strict you are over here, but feel free to ask me to create a new topic somewhere else.

We do not support vibrating the device for push notifications.  Engineering explained it to me and I’m not sure how well I can articulate the issue, but it would involve having to add some features to let the users control the feature and that turning it on for everyone would cause more issues than not supporting it at all.  Due to the complexity and limited utility of the feature, it’s not going to be a high priority feature to add, but if you add it at http://feedback.coronalabs.com and get people to vote up its importance, it would potentially move it up the priority list.

Thanks for you answer!

I can understand the issue with turning it on for everyone since it would change the behavior of many apps unexpectedly, but as a new user of the API, I would expect every notification with a sound to fall back to vibration of the sound is disabled. Think of all everyday apps that use notifications: Mail, SMS etc. They all use vibration.

I can’t really argue with the complexity since I have no insight of how this stuff works on the iOS side of things, but I cannot agree with “limited utility of the feature”. In my option, all notifications that are interesting to the user should use vibration. Non-interesting notifications are just annoying, so ideally all notifications in my world should have vibration. For a turn based game (think Wordfeud) having no indication that it’s your turn would slow down a game a lot if just playing it casually while doing something else.

This could be a dealbreaker for us, and I would like ask you to reconsider the decision of not including vibration in the notification API.

For those who find this topic and also need the feature, I’ve added it to corona feedback.

Local/Push Notifications vibration on corona feedback

I think that’s not a “limited utility of the feature” almost all successful games have a notification module, that makes the phone vibrate. Or when you are hitted by something, I can think a million of cases where the vibration can be used. I was searching in the forum and there’s a lot of question of people asking for this feature. At least say that’s not supported I’ve lost 8 hrs yesterday trying to make it work. There’s also a video of Corona explain how to do it. The other people who asked for this should know about the issue.

Local/Push Notifications vibration on corona feedback

To clarify, this issue only regards vibration in push or local notifications, the system.vibrate() api works great from ingame. The limitation is that the app has to be running in order to vibrate (which usually isn’t the case with push notifications).

But I fully agree that a notification module without vibration is far less useful than a fully featured one.

diego.unanue, I bet your problem is that you use --[[…]]-- around your android permissions block, which makes it a comment. If you use a editor with proper syntax highlighting, you will see that a large portion of your file is grayed out marking it as a comment. See this pastebin for an example of syntax highlighting: http://pastebin.com/RFNtY0SZ

Yes, that was the problem. the --[[…]]–.

This is my build.settings for those with the same problem (android chash when try to vibrate) my Android is 4.3 and it works perfectly now with the following code.

settings =
{
    orientation = {
        default = “portrait”,
        supported = { “portrait”, }
    },

    iphone =
    {
        plist=
        {
            CoronaUseIOS7LandscapeOnlyWorkaround = true,
            CoronaUseIOS7IPadPhotoPickerLandscapeOnlyWorkaround = true,
            CoronaUseIOS6LandscapeOnlyWorkaround = true,
            CoronaUseIOS6IPadPhotoPickerLandscapeOnlyWorkaround = true,
            UIApplicationExitsOnSuspend = false,
            UIPrerenderedIcon = true,
            UIStatusBarHidden = false,
            CFBundleIconFile = “Icon.png”,
            CFBundleIconFiles =
            {
                “Icon.png”,
                “Icon@2x.png”,
                “Icon-60.png”,
                “Icon-60@2x.png”,
                “Icon-72.png”,
                “Icon-72@2x.png”,
                “Icon-76.png”,
                “Icon-76@2x.png”,
                “Icon-Small.png”,
                “Icon-Small@2x.png”,
                “Icon-Small-40.png”,
                “Icon-Small-40@2x.png”,
                “Icon-Small-50.png”,
                “Icon-Small-50@2x.png”,
            },
        },
    },
    android =
    {
        permissions =
        {
            { name = “.permission.C2D_MESSAGE”, protectionLevel = “signature” },
        },
        usesPermissions =
        {
            “android.permission.INTERNET”,
            “android.permission.VIBRATE”,
        },
    },
}
 

Hi, Rob~

Now vibration for notifications is not supported, but is there a plan to support it in the near future?

I hope so.

I think it is very useful and important to re-engage existing users to come back into a game. 

I doubt there are plans for adding this feature in the near future.

Rob

I wish there was a way to convince you to add support for this feature.

In native Android adding vibration is just as easy as adding support for sound. When creating the notification with the Android SDK you just have to add one extra line of code:

Notification notification = new Notification( .. ); notification.sound = soundUri; notification.vibrate = new long[]{100, 100};

I don’t really see the complexity of adding notification support since you already support sound which to me looks harder. All you’d have to do is to add one extra property to the table creating the notification along with sound. And while you are at it, you could also easily add notification lights and get two features at once.

Now this is of course only for android, but I don’t see any reason why Apple would make it much harder. They definitely do support it.

Please do consider adding vibration support to the notifications. It’s really important to my app and would help many others as well.

The problem isn’t adding the vibration.  It in itself isn’t difficult.  It’s how to you handle when you want it and the next developer does not, or when one of your customers wants it and another one does not.  I asked and Engineering said they have considered this and it’s not a high priority item.

Rob

I havet the same problem. Sound works just fine. I have verified that my app has the vibrate permission from the app info dialog.

I am Starting to think that vibration isn’t supported? Is there anything special data you have to send in the push? I am using a custom push server if that matters.

Thanks!