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.

LM Home app (Andrоid/iOS starter)
1. Check that "Remember login and password" is enabled in LM > Users > User access settings. Don't use admin user for the app. Keep the app running in the background after the first login otherwise the credentials might not be saved.

2. Create a user library named push, provide user names, tokens and create groups as needed.
Code:
local tokens = {
  ['User A'] = 'user-token-A',
  ['User B'] = 'user-token-B',
  ['User C'] = 'user-token-C',
}

local groups = {
  ['Group A'] = { 'User A', 'User B' },
  ['Group B'] = { 'User B', 'User C' },
}

return function(name, title, body)
  local push = require('applibs.lmcloud.push')

  local token = tokens[ name ]
  if token then
    return push(token, title, body)
  end
  
  local group = groups[ name ]
  if group then
    local ress, errs = {}, {}
    
    for _, tname in ipairs(group) do
      token = tokens[ tname ]
      
      if token then
        local res, err = push(token, title, body)
        if res then
          ress[ name ] = true
        else
          errs[ name ] = err
        end
      else
        errs[ name ] = 'not found'
      end
    end
    
    return ress, errs
  end
  
  return nil, 'not found'  
end

Usage:
Code:
push = require('user.push')

name = 'Group A'
title = 'Push title'
body = 'Push message body'

res, err = push(name, title, body)
log(res, err)
Reply


Messages In This Thread
LM Home app (Andrоid/iOS starter) - by admin - 30.01.2024, 10:58
RE: LM Home app (Andrоid/iOS starter) - by admin - 17.02.2025, 08:00

Forum Jump: