Jump to: navigation, search

Push system API

Revision as of 14:45, 22 October 2014 by Huangyanli (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Push system

Developers can send push notifications to its users in a timely manner, interact anytime with users and directly enhance the user experience. This document will explain how to use AnySDK to integrate push notification service

Terminology explanation

Alias

To provide an alias to identify users who installed the app. In the future when sending a push notification to a user, they can be identified by this alias.
1.Every user can only have one alias.
2.Different users should get different aliases within one app. This way every alias is unique to one user and they can be better identified.
3.The system does not restrict one alias to be used by one user only. If one alias is used by multiple users and it is determined that this alias will receive a push, the server API will send a push to these users (having the same alias) at the same time.
For example: An user logs in to a game, and sets his alias as “userid”. When the game runs and discovers that this user has not played this game for 3 days, “userid” will request the server API to send a push to the client to remind this user.

Tag

Add a tag to users who installed the app. Its purpose is mainly to making it more convenient for developers to send push notifications in batches based on these tags.
1.Possible to add multiple tags to every user.
2.Different apps and different users can have the same tag.
For example: game, old_page, women

Setting listener

Settings

Setting listener for push notification system.
    if(AgentManager::getInstance()->getPushPlugin())
    {
        AgentManager::getInstance()->getPushPlugin()->setActionListener(this);
    }

Callback information

Callback information code msg
Receive push notification kPushReceiveMessage Message information
To receive callbacks, onActionResult methods needs to be overriden.
class Push:public PushActionListener
{
public:
	 virtual void onActionResult(ProtocolPush* pPlugin, PushActionResultCode code, const char* msg);
}

Related APIs

Start service

void startPush() ;
Function description:
Start push service
For example
// Start push
void Push::startPush()
{
	 if(AgentManager::getInstance()->getPushPlugin())
	 {
	     AgentManager::getInstance()->getPushPlugin()->startPush();
	 }
}

Close push service

void stopPush() ;
Function description:
Function description
For example
//Close push service
void Push::closePush()
{
	 if(AgentManager::getInstance()->getPushPlugin())
	 {
		 AgentManager::getInstance()->getPushPlugin()->closePush();
	 }

}

Set alias

void setAlias(string alias);
Function description:
Set alias for application
For example
// Set alias
void Push::setAlias()
{
	if(AgentManager::getInstance()->getPushPlugin())
	{
		AgentManager::getInstance()->getPushPlugin()->setAlias("AnySDK");
	}


}

Delete alias

void delAlias(string alias);
Function description:
Delete current alias
For example
// Delete alias
void Push::delAlias()
{
	if(AgentManager::getInstance()->getPushPlugin())
	{
		AgentManager::getInstance()->getPushPlugin()->delAlias("AnySDK");
	}


}

Set tag

void setTags(list<string> tags);
Function description:
Set tags for application
For example
//Set tag
void Push::setTags()
{
	if(AgentManager::getInstance()->getPushPlugin())
	{
		list<string> tags;
		tags.push_back("easy");
		tags.push_back("fast");
		AgentManager::getInstance()->getPushPlugin()->setTags(tags);
	}

}

Delete tag

void delTags(list<string> tags);
Function description:
Delete current tags for this application
For example
//Delete tags
void Push::delTags()
{
	if(AgentManager::getInstance()->getPushPlugin())
	{
		list<string> tags;
		tags.push_back("easy");
		tags.push_back("fast");
		AgentManager::getInstance()->getPushPlugin()->delTags(tags);
	}

}

Please note

Push notification to umeng

umeng push notification currently does not support custom messages and custom actions.