Logic Machine Forum
Push notifications from LM to iOS and Android devices - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Push notifications from LM to iOS and Android devices (/showthread.php?tid=1083)

Pages: 1 2 3


RE: Push notifications from LM to iOS and Android devices - Daniel - 10.02.2022

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



RE: Push notifications from LM to iOS and Android devices - Shimaa - 10.02.2022

I tried this script also: 


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)



Besides trying your third method of FB editor but non of them worked.

(10.02.2022, 13:08)Daniel Wrote: Use this as described above
Code:
pusher = require('applibs.pusher')
status, errors = pusher.send('custom name or ID', 'Test Message')
log(status, errors)

No notification sent


RE: Push notifications from LM to iOS and Android devices - admin - 10.02.2022

What do you get in Logs and Error log?


RE: Push notifications from LM to iOS and Android devices - Shimaa - 10.02.2022

(10.02.2022, 13:18)admin Wrote: What do you get in Logs and Error log?

User script:2: attempt to index global 'pusher' (a nil value)
stack traceback:
User script:2: in main chunk

cannot open /home/apps/store/data/cloud/lua/pusher: No such file or directory
stack traceback:
[C]: in function 'dofile'
User library Notifications:33: in function 'fbe_pushAndroid'
User script:6: in main chunk


RE: Push notifications from LM to iOS and Android devices - Daniel - 10.02.2022

Make sure you use latest app.


RE: Push notifications from LM to iOS and Android devices - Shimaa - 10.02.2022

(10.02.2022, 13:29)Daniel Wrote: Make sure you use latest app.
Yes I'm using the latest one on the play store which was last updated on Dec 8, 2021


RE: Push notifications from LM to iOS and Android devices - Daniel - 10.02.2022

App on LM store for push notification.


RE: Push notifications from LM to iOS and Android devices - Shimaa - 10.02.2022

(10.02.2022, 13:35)Daniel Wrote: App on LM store for push notification.

Version 20211216


RE: Push notifications from LM to iOS and Android devices - icuzz - 10.02.2022

Well I have problem with getting the UID to show up with push notification app. Using android 12. Latest firmware on LM and latest apps, both phone and LM and I was locally connected. Also tried to remove all the apps(phone/server) and cloud connections and tried again to get the push notification to show the phone. You should make push notifications work with the app automatically if push notification is selected, but still the UID is also nice, because you can do custom notifications to certain phone/tablets.


RE: Push notifications from LM to iOS and Android devices - Daniel - 10.02.2022

(10.02.2022, 13:46)icuzz Wrote: Well I have problem with getting the UID to show up with push notification app. Using android 12. Latest firmware on LM and latest apps, both phone and LM and I was locally connected. Also tried to remove all the apps(phone/server) and cloud connections and tried again to get the push notification to show the phone. You should make push notifications work with the app automatically if push notification is selected, but still the UID is also nice, because you can do custom notifications to certain phone/tablets.

There is known issue with this. Do as fallow.
Add device and enable notification, save.
Edit the device and disable notifications and save.
Edit the device again and enable notifications and save.
Now it will be added.


RE: Push notifications from LM to iOS and Android devices - icuzz - 10.02.2022

(10.02.2022, 13:48)Daniel Wrote:
(10.02.2022, 13:46)icuzz Wrote: Well I have problem with getting the UID to show up with push notification app. Using android 12. Latest firmware on LM and latest apps, both phone and LM and I was locally connected. Also tried to remove all the apps(phone/server) and cloud connections and tried again to get the push notification to show the phone. You should make push notifications work with the app automatically if push notification is selected, but still the UID is also nice, because you can do custom notifications to certain phone/tablets.

There is known issue with this. Do as fallow.
Add device and enable notification, save.
Edit the device and disable notifications and save.
Edit the device again and enable notifications and save.
Now it will be added.

And this has to be done locally?


RE: Push notifications from LM to iOS and Android devices - Daniel - 10.02.2022

Yes always locally.


RE: Push notifications from LM to iOS and Android devices - Daniel - 10.02.2022

(10.02.2022, 13:39)Shimaa Wrote:
(10.02.2022, 13:35)Daniel Wrote: App on LM store for push notification.

Version 20211216

Can I get remote access? Zerotier would do. If yes send to PM.


RE: Push notifications from LM to iOS and Android devices - icuzz - 10.02.2022

(10.02.2022, 13:51)Daniel Wrote: Yes always locally.

ok, thx. I will try this. This is huge problem, because my customers are not so tech-savvy so telegram notification is too complex and even do this is too complex and I can't install all the apps on every device Smile . Even the android app is too complex without a guide to get it working, too many options Smile .


RE: Push notifications from LM to iOS and Android devices - Shimaa - 10.02.2022

(10.02.2022, 13:52)Daniel Wrote:
(10.02.2022, 13:39)Shimaa Wrote:
(10.02.2022, 13:35)Daniel Wrote: App on LM store for push notification.

Version 20211216

Can I get remote access? Zerotier would do. If yes send to PM.

yes sure, I've signed in Zerotier right now.

(10.02.2022, 14:01)Shimaa Wrote:
(10.02.2022, 13:52)Daniel Wrote:
(10.02.2022, 13:39)Shimaa Wrote:
(10.02.2022, 13:35)Daniel Wrote: App on LM store for push notification.

Version 20211216

Can I get remote access? Zerotier would do. If yes send to PM.

I'm new in zerotier, and I've sent my network Id in a private message, please check.
yes sure, I've signed in Zerotier right now.
[/quote]

(10.02.2022, 14:01)Shimaa Wrote:
(10.02.2022, 13:52)Daniel Wrote:
(10.02.2022, 13:39)Shimaa Wrote:
(10.02.2022, 13:35)Daniel Wrote: App on LM store for push notification.

Version 20211216

Can I get remote access? Zerotier would do. If yes send to PM.

yes sure, I've signed in Zerotier right now.

(10.02.2022, 14:01)Shimaa Wrote:
(10.02.2022, 13:52)Daniel Wrote:
(10.02.2022, 13:39)Shimaa Wrote:
(10.02.2022, 13:35)Daniel Wrote: App on LM store for push notification.

Version 20211216

Can I get remote access? Zerotier would do. If yes send to PM.
 
I'm new in zerotier, and I've sent my network Id in a private message, please check.
yes sure, I've signed in Zerotier right now.
Sorry I can't see you in ZeroTier, can you please check your inbox, Thanks for your time.


RE: Push notifications from LM to iOS and Android devices - Josema - 06.12.2022

(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.


RE: Push notifications from LM to iOS and Android devices - Daniel - 07.12.2022

After this line it is shown exactly, change this ...to this... but this is only needed if you were using old functions.


RE: Push notifications from LM to iOS and Android devices - Josema - 07.12.2022

(07.12.2022, 14:22)Daniel Wrote: After this line it is shown exactly, change this ...to this... but this is only needed if you were using old functions.
 
Good evening Daniel, with the help of my daughter I have seen that there was a file that I had not downloaded to the library, I have already done it (until now I did NOT use push notifications), I am going to see if I am able to get push notifications.

Best Regards


RE: Push notifications from LM to iOS and Android devices - AISystem - 10.11.2023

Hello, I am trying to connect app notifications, but in LM push notifications, my device is not coming out. I am connected to the cloud and using the following code:

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

I get this in the logs:

*arg: 1
  * nil
*arg: 2
  * string: no devices to send to

I'm running the latest firmware and the lmcloud, mosaic and LM push notifications apps are up to date.
What am I missing?


RE: Push notifications from LM to iOS and Android devices - Daniel - 10.11.2023

Obviously you didn't add any android device to push app. The common mistake is to configure android app before LM.
Make sure you are on the same local network as LM. Go to LM android app, edit your user, disable push notification, save then edit and enable again and save.
Refresh push notification app in LM to see if your device was added. You can then test it directly from the app.