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

Nice API design!

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

@Simeon Thanks, you can indeed but you should check ~Notifications.hasPermission()~ before doing so otherwise you’ll just get a warning.

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.

@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!

So cool! Much appreciated!

Is there a way to read the messages?

@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!)

That worked perfectly! :smile:

@Simeon Ah, amazing!