This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Push notifications from LM to iOS and Android devices
#36
(08.11.2017, 17:29)Daniel Wrote: New push notification app was released and it fully replace old one. New app is called simply 'Push notifications' and old 'Cloud' is taken off the store. New app is using new cloud, to use it you must register in https://remote.logicmachine.net/user and use LM Cloud app to synchronize.
How to do it you see here:


The rest is nearly the same as in old app. Old functions are backward compatibly only the call to library must be changed.

Change this
Code:
pusher = dofile("/home/apps/store/data/cloud/lua/pusher.lua")

to this

Code:
pusher = require('applibs.pusher')


To simplify work we created new functions which can be used to work with new app. In new app each device can have custom name and we can use it instead of the ID. The ID is still working but it is much more convenient to use just custom name.

Fallowing functions are possible:

Send to individual device by ID or Name

Code:
pusher = require('applibs.pusher')
status, errors = pusher.send('custom name or ID', 'Test Message')
log(status, errors)


Send to all Android devices:

Code:
pusher = require('applibs.pusher')
status, errors = pusher.send_android('Test Message')
log(status, errors)

Send to all iOS devices

Code:
pusher = require('applibs.pusher')
status, errors = pusher.send_ios('Test Message')
log(status, errors)



Send to all devices

Code:
pusher = require('applibs.pusher')
status, errors = pusher.send_all('Test Message')
log(status, errors)


Below is the description for the old 'cloud' app. If for some reason anybody needs it I'm attaching it below.







Here are the used scripts.



Script 1 for both iOS and Android



Code:
pusher = dofile("/home/apps/store/data/cloud/lua/pusher.lua")

status, errors = pusher.push_notification('08a7a67cc15d5325c0bbaffbd1106c0e5a914b8ea6e850f4210a4a2cd260c835', 'Test Message')
log(status, errors)


Script 2 for iOS - will send to all iOS devices



Code:
pusher = dofile("/home/apps/store/data/cloud/lua/pusher.lua")

local ids= {}
for _, d in ipairs(pusher.get_ios_devices()) do
table.insert(ids, d.id)
end
local status,errors = pusher.push_notification(ids, 'Your house is on FIRE!')
log(status,errors)




Script 2 for Android devices - will send to all android devices





Code:
pusher = dofile("/home/apps/store/data/cloud/lua/pusher.lua")


local ids = {}
for _, d in ipairs(pusher.get_android_devices()) do
table.insert(ids, d.id)
end

local status, errors = pusher.push_notification(ids, 'Your house is on FIRE!')
log(status, errors)
 P
 I



And library for FB editor in attachment



Have fun!

I don't know where do I have to write the code to activate the push notifications, when you say "the call to library must be changed" where do I have to write this code?
Best regards.
Reply


Messages In This Thread
RE: Push notifications from LM to iOS and Android devices - by Josema - 06.12.2022, 18:42

Forum Jump: