This plugin was created based on Huawei Push Kit. Please check for detailed information about Huawei Push Kit.
In order to use the Huawei Push Kit, you must first create an account from developer.huawei.com. And after logging in with your account, and then you must create a project in the huawei console in order to use HMS kits.
To use the plugin please add following to build.settings
{
plugins = {
["plugin.huaweiPushKit"] = {
publisherId = "com.solar2d",
},
},
}
After you need to define the plugin in main.lua.
local pushKit = require "plugin.huaweiPushKit"
local function listener( event )
print( event.message )
end
pushKit.init( listener )
Provides methods for obtaining the AAID and tokens required for accessing Push Kit.
Obtains an AAID in synchronous mode.
pushKit.HmsInstanceId("getId")
--Result(String)
Obtains an AAID in asynchronous mode.
pushKit.HmsInstanceId("getAAID", function(event)
print(event.message)
end)
--Result(String)
Obtains the generation timestamp of an AAID.
pushKit.HmsInstanceId("getCreationTime")
--Result(Integer)
Deletes a local AAID and its generation timestamp.
pushKit.HmsInstanceId("deleteAAID")
--Result(Void)
Obtains a token required for accessing Push Kit.
pushKit.HmsInstanceId("getToken")
-- Result(String)
local function listener( event )
if event.type == "getToken" then
if not event.isError then
token = event.message
end
end
end
Deletes a token.
pushKit.HmsInstanceId("deleteToken")
--Result(Void)
Deletes a token.
pushKit.HmsInstanceId("deleteToken", {subjectId=""})
--Result(Void)
Provides the method for obtaining an open device identifier (ODID).
Obtains an AAID in asynchronous mode.
pushKit.OpenDeviceClient("getOdid", function(event)
print(event.isError, event.message)
end)
--Result(String)
Provides methods for subscribing to topics and for enabling or disabling the function of receiving notification messages.
Checks whether automatic initialization is enabled.
pushKit.HmsMessaging("isAutoInitEnabled")
--Result(boolean)
Sets whether to enable automatic initialization.
pushKit.HmsMessaging("setAutoInitEnabled", {enable=false})
--Result(Void)
Subscribes to topics in asynchronous mode.
pushKit.HmsMessaging("subscribe", {topic = ""}, function(event)
print(event.isError)
end)
--Result(Void)
Subscribes to topics in asynchronous mode.
pushKit.HmsMessaging("unsubscribe", {topic = ""}, function(event)
print(event.isError)
end)
--Result(Void)
Enables the display of notification messages.
pushKit.HmsMessaging("turnOnPush", function(event)
print(event.isError)
end)
--Result(Void)
Disables the display of notification messages.
pushKit.HmsMessaging("turnOffPush", function(event)
print(event.isError)
end)
--Result(Void)
A class for checking whether to display messages for the user based on the account.
Checks whether the device supports account verification.
pushKit.HmsProfile("isSupportProfile")
--Result(boolean)
Adds the relationship between the user and app on the device.
pushKit.HmsProfile("addProfile", {profileId="", type=1}, function(event)
print(event.isError)
end)
pushKit.HmsProfile("addProfile", {profileId="", type=1, subjectId=""}, function(event)
print(event.isError)
end)
--Result(Void)
Deletes the relationship between the user and app on the device.
pushKit.HmsProfile("deleteProfile", {profileId=""}, function(event)
print(event.isError)
end)
pushKit.HmsProfile("deleteProfile", {subjectId="", profileId=""}, function(event)
print(event.isError)
end)
--Result(Void)
pushKit.HmsProfile("HUAWEI_PROFILE")
-- Result (1)
pushKit.HmsProfile("CUSTOM_PROFILE")
-- Result (2)
HMS Push Kit here HMS Push Kit Server Side Development here HMS Push Kit FAQ here HMS Push Kit Result Codes here
MIT