7 Replies Latest reply on May 29, 2016 11:38 AM by Terushkan

    Alarm clock app - Help badly needed!

    umairl41606814

      I desperately need help!

       

      Being a newbie in mobile development, I've started off with the basic example on Phonegap website - and I'm using CLI to deploy code into the Phonegap mobile app (which runs my code within it - makes deployment easier).

       

      The app I want to create needs to do this:

      - Let user select a time for an alarm: EASY

      - At the time of the alarm, the app should evaluate some stuff and potentially reschedule the alarm to go off at a later time: IHAVENOIDEAWHATTODO

       

      My initial approach was to find a way to let code continue executing even if the app has been closed. This would let me achieve the 'evaluate some stuff at the time of alarm' part and rescheduling. So one of the plugins I've tried to achieve this is: GitHub - katzer/cordova-plugin-background-mode: Keep app running in background

       

      This plugin does not actually work. The code execution seems to stop as soon as I try to use any function listed in that plugin's documentation. Maybe because that plugin hasn't been modified to work with the latest phonegap version.

       

      I can't find any good alarm plugin either.

       

      Just some extra info: hoping to develop for Android and IOS though currently only testing on Android.

       

      PLEASE HELP! I WILL BE ETERNALLY GRATEFUL TO WHOMEVER HELPS ME RESOLVE THESE ISSUES.

        • 1. Re: Alarm clock app - Help badly needed!
          kerrishotts Adobe Community Professional

          I think you're looking for local notifications. There's a plugin that might be of use for you: de.appplant.cordova.plugin.local-notification

           

          Also note that you shouldn't rely on running code in the background, especially on iOS. Apple will reject using the particular plugin you're using, as there are only certain features that get background access (audio, GPS, downloading[10m], etc.)

           

          Hope that helps!

          • 2. Re: Alarm clock app - Help badly needed!
            umairl41606814 Level 1

            Thanks Kerri! Finally managed to get Cordova plugins running (it was a silly mistake on my part). Also, LocalNotifications seems near perfect for my needs!

             

            One concern I have at this point is whether IOS will allow me to publish an app using this plugin. I've contacted them separately but I'm not sure if they will respond back that soon.

             

            The other concern I have is that given what I'm creating is an alarm, the sound is the most important thing. The sound in this case comes under 'notification' so if someone has their notification volume at 0 (to avoid unnecessary social network updates while sleeping) it will be a problem. Any suggestions for this?

            • 3. Re: Alarm clock app - Help badly needed!
              kerrishotts Adobe Community Professional

              Thanks Kerri! Finally managed to get Cordova plugins running (it was a silly mistake on my part). Also, LocalNotifications seems near perfect for my needs!

              Glad that seems to work for you! :-)

               

              One concern I have at this point is whether IOS will allow me to publish an app using this plugin. I've contacted them separately but I'm not sure if they will respond back that soon.

              Local notifications is an iOS feature, so Apple should not reject for using it. Make sure to remove the background plugin, since that will cause a rejection.

               

              The other concern I have is that given what I'm creating is an alarm, the sound is the most important thing. The sound in this case comes under 'notification' so if someone has their notification volume at 0 (to avoid unnecessary social network updates while sleeping) it will be a problem. Any suggestions for this?

              This article might be of interest to you: How Do Alarm Clock Apps Work on iOS? – Ole Begemann

              • 4. Re: Alarm clock app - Help badly needed!
                umairl41606814 Level 1

                I don't really get that Kerri.

                 

                I've tried the plugin on Android and it does wake the app up even if the screen has gone black. And the issue about the sound only working for 30 seconds, surely that can be overcame by setting 2 local notifications 30 seconds apart if you wanted it to continue for 1 minute or however long. Maybe the issues mentioned on that page are only applicable to IOS?

                 

                Also, this is probably to do with the fact I'm a beginner at mobile development but I didn't get their proposed solution at all. Do you mind explaining how I'd use that with phonegap?

                • 5. Re: Alarm clock app - Help badly needed!
                  kerrishotts Adobe Community Professional

                  Yes, the issues mentioned are only applicable to iOS. iOS alarm apps are typically quite hamstrung. Maybe one day Apple will relax a little bit.

                   

                  Keep in mind that I'm not an expert on the proposed solution, but the way I understand it is that by disabling multitasking, the app is now allowed to run even while the screen is locked. This means that the app can still do whatever processing it needs to do -- which, for some apps might be quite extensive. (Consider apps that measure movement during sleep or the like.) In this scenario, your app is running for the duration of the night, and so all it needs to do is wait for the alarm time. Then it can do whatever it wants, including playing the sound for how long it wants, at what volume it wants, etc.

                   

                  This doesn't preclude the possibility of your app being terminated for some reason, so you still need local notifications. Unfortunately, these are still subject to the issues otherwise mentioned.

                   

                  Update: This thread (https://muut.com/i/appgyver/steroids:how-to-keep-app-running-aft ) indicates that this particular functionality may not work on iOS 7+. If so, you're probably best off adding some ancillary feature like a cool clock screen so that the user doesn't mind leaving the device on.

                  • 6. Re: Alarm clock app - Help badly needed!
                    umairl41606814 Level 1

                    Hi Kerri, if it's really simple for you (you have a mac, iphone, and phonegap set up) - do you mind testing what actually happens with the LocalNotifications app. It's a big ask I know but asking someone to test this out is my only option.

                    • 7. Re: Alarm clock app - Help badly needed!
                      Terushkan

                      Hi There!!! I am a newbie too and I see you find getting the user to set the alarm quite simple. Can you please give me some advise on how you did this? struggling!!!

                       

                      Thanks so much