Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Local Notifications Library (Also on WebRepo)

Hi all,

If anybody is interested, here’s a library to ease working with simple local notifications in Codea.
You can schedule notifications to be sent after a specified number of seconds (among other notification management things).

I’m not quite sure I even needed it for anything but it was a good test of what can be done with the new ObjC bindings.
I hope it’s of use to someone at least :smile:

Example usage (included in project):

function setup()
    Notifications.setup(function(hasPermission)

        -- Title, Description & Delay (5 seconds)
        local notificationId = Notifications.scheduleNotification("Demo", "Look at this amazing demo", 5)

    end)
end
Tagged:

Comments

  • SimeonSimeon Admin Mod
    Posts: 5,759

    Nice API design!

    I assume you can call scheduleNotification outside of the Notifications.setup function?

  • Posts: 327
    @Simeon Thanks, you can indeed but you should check ~Notifications.hasPermission()~ before doing so otherwise you'll just get a warning.
  • edited January 16 Posts: 35

    Hello! Do you know if it’s possible to vibrate a device using objC? I’m new to Codea and iOS so forgive me if it’s a silly question.

  • edited January 15 Posts: 327

    @arismoko I do believe it should be possible, leave it with me for a few days and I’ll try to put a library together.

    It’s actually a fantastic idea!

  • Posts: 35

    So cool! Much appreciated!

  • Posts: 1,303

    Is there a way to read the messages?

  • SimeonSimeon Admin Mod
    Posts: 5,759

    @arismoko @Steppers if you want to get started on haptics (vibration) you can try this:

    function touched(touch)
        if touch.state == ENDED then
            local gen = objc.cls.UIImpactFeedbackGenerator()
            gen:impactOccurred()
        end
    end
    

    (Requires iPhone. iPad has no haptics!)

  • Posts: 35
    That worked perfectly! :smile:
  • Posts: 327

    @Simeon Ah, amazing!

Sign In or Register to comment.