DELPHI实现消息推送:个推C语言的DLL如何在DELPHI7中调用,我想知道如何转换,谢谢!以下是C的原形声明。
#ifndef _I_GT_PUSH_H_
#define _I_GT_PUSH_H_
/***************************版本修改日志***************************
* ==========V1.0.1, chenjb, 2014-07-28==========
* 1. 去除pushMessageToListB接口,pushMessageToListA改名为pushMessageToList
* 2. pushMessageToList增加返回推送详情功能
*
* ==========V1.0.2, chenjb, 2015-01-14==========
* 1. curl bug修改,http://blog.chinaunix.net/uid-20761674-id-3391182.html
*/
#ifdef __cplusplus
extern "C" {
#endif
#if defined(WIN32) || defined(_WIN32)
# define STDCALL _stdcall
# if defined(GTPUSHSDK_EXPORTS)
# define DLL_EXTERN __declspec(dllexport)
# else
# define DLL_EXTERN __declspec(dllimport)
# endif
#else
# define DLL_EXTERN
# define STDCALL
#endif
// 调用返回结果结构体:SUCCESS(成功)/FAILED(失败)
typedef enum result_t {
SUCCESS = 0,
FAILED = 1,
ERR_ENCODE = 2
} Result;
// 单个结果键值对结构体
typedef struct entry_t {
char key[100];
char value[1024];
} Entry;
// 推送结果结构体
typedef struct i_push_result_t {
int size; // 结果中存在多少个Entry
Entry entry[10];
} IPushResult;
// 基本消息结构体
typedef struct message_t {
int isOffline;
long offlineExpireTime;
int priority;
} Message;
// 单个消息结构体
typedef struct single_message_t {
Message msg;
} SingleMessage;
// CID列表消息结构体
typedef struct list_message_t {
Message msg;
} ListMessage;
// 应用消息结构体
typedef struct app_message_t {
Message msg;
char **appIdList;
int appIdListSize;
char **phoneTypeList;
int phoneTypeListSize;
char **provinceList;
int provinceListSize;
char **tagList;
int tagListSize;
} AppMessage;
// 推送目标结构体
typedef struct target_t {
char *appId;
char *clientId;
} Target;
// 模板类型枚举
typedef enum template_type_t {
Transmission, PopupTransmission, NotyPopLoad, Notification, Link
} TemplateType;
// 应用于IOS手机
typedef struct push_info_t {
char *actionLocKey;
int badge;
char *message;
char *sound;
char *payload;
char *locKey;
char *locArgs;
char *launchImage;
} PushInfo;
// 基本模板结构体
typedef struct template_t {
char *appId;
char *appKey;
PushInfo pushInfo;
} Template;
// 透传模板结构体
typedef struct transmission_template_t {
Template t;
int transmissionType;
char *transmissionContent;
} TransmissionTemplate;
// 弹窗透传模板结构体
typedef struct popup_transmission_template_t {
Template t;
int transmissionType;
char *transmissionContent;
char *title;
char *text;
char *img;
char *confirmButtonText;
char *cancelButtonText;
} PopupTransmissionTemplate;
// 通知弹窗下载模板结构体
typedef struct noty_pop_load_template_t {
Template t;
char *notyIcon;
char *logoUrl;
char *notyTitle;
char *notyContent;
int isCleared;
int isBelled;
int isVibrationed;
char *popTitle;
char *popContent;
char *popImage;
char *popButton1;
char *popButton2;
char *loadIcon;
char *loadTitle;
char *loadUrl;
int isAutoInstall;
int isActived;
char *androidMark;
char *symbianMark;
char *iphoneMark;
} NotyPopLoadTemplate;
// 通知模板结构体
typedef struct notification_template_t {
Template t;
int transmissionType;
char *transmissionContent;
char *text;
char *title;
char *logo;
char *logoUrl;
int isRing;
int isVibrate;
int isClearable;
} NotificationTemplate;
// 链接模板结构体
typedef struct link_template_t {
Template t;
char *text;
char *title;
char *logo;
char *logoUrl;
char *url;
int isRing;
int isVibrate;
int isClearable;
} LinkTemplate;
// 推送结果详情
typedef struct push_detail_t {
char cid[33]; // 对应的CID
char ret[51]; // 详情内容
} PushDetail;
// 功能:推送初始化,程序运行前初始化一次即可
// 参数:
// host 个推服务器URL [in]
// appKey 个推申请应用的appKey [in]
// masterSecret 个推申请应用的masterSecret [in]
// testUTF8 本库所有接口必须传入字符必须为UTF-8编码,这里用于测试是否是UTF-8编码,固定填写"编码"两字 [in]
// 返回:Result枚举, SUCCESS、FAILED、ERR_ENCODE(编码测试失败)
DLL_EXTERN Result STDCALL pushInit(char *host, char *appKey, char *masterSecret, const char *testUTF8);
// 功能:初始化个推服务器鉴权
// 参数:
// appKey 调用pushInit时APP对应的appKey [in]
// 返回:Result枚举, SUCCESS、FAILED
DLL_EXTERN Result STDCALL pushConnect(char *appKey);
// 功能:关闭个推服务器鉴权
// 参数:
// appKey 调用pushInit时APP对应的appKey [in]
// 返回:Result枚举, SUCCESS、FAILED
DLL_EXTERN Result STDCALL pushClose(char *appKey);
// 功能:推送单条消息
// 参数:
// appKey 调用pushInit时APP对应的appKey [in]
// msgData 单推消息结构体指针 [in]
// templateData 模板结构体指针 [in]
// templateType 模板类型 [in]
// target 推送目标结构体指针 [in]
// 返回:推送结果数据
DLL_EXTERN IPushResult STDCALL pushMessageToSingle(char *appKey, SingleMessage *msgData, void *templateData, TemplateType templateType, Target *target);
// 功能:获取contentId,用于pushMessageToListA接口
// 参数:
// appKey 调用pushInit时APP对应的appKey [in]
// msgData CID列表消息结构体指针 [in]
// templateData 模板结构体指针 [in]
// templateType 模板类型 [in]
// contentId 用于返回contentId的指针 [out]
// size 可存放contentId的大小 [in]
// 返回:Result枚举, SUCCESS、FAILED
// 注意:如果size小于返回的ID,则返回FAILED
DLL_EXTERN Result STDCALL getContentId(char *appKey, ListMessage *msgData, void *templateData, TemplateType templateType, char *contentId, int size);
// 功能:取消contentId
// 参数:
// appKey 调用pushInit时APP对应的appKey [in]
// contentId 需要取消的contentId [in]
// 返回:Result枚举, SUCCESS、FAILED
DLL_EXTERN Result STDCALL cancelContentId(char *appKey, char *contentId);
// 功能:推送CID列表
// 参数:
// appKey 调用pushInit时APP对应的appKey [in]
// contentId 由getContentId返回的contentId [in]
// targetList 需要推送的目标列表 [in]
// targetSize 目标列表中有多少个Targe,建议每次50 [in]
// details 推送详情内容,不需要详情可填写NULL,否则需要预先分配足够内存(至少要targetSize个PushDetail) [in]
// 返回:Result枚举, SUCCESS、FAILED
DLL_EXTERN IPushResult STDCALL pushMessageToList(char *appKey, char *contentId, Target *targetList, int targetSize, PushDetail *details);
// 功能:推送应用消息
// 参数:
// appKey 调用pushInit时APP对应的appKey [in]
// msgData 应用消息结构体指针 [in]
// templateData 模板结构体指针 [in]
// templateType 模板类型 [in]
// 返回:推送结果数据
DLL_EXTERN IPushResult STDCALL pushMessageToApp(char *appKey, AppMessage *msgData, void *templateData, TemplateType templateType);
// 功能:停止推送某个任务
// 参数:
// appKey 调用pushInit时APP对应的appKey [in]
// contentId 需要停止推送的contentId [in]
// 返回:Result枚举, SUCCESS、FAILED
DLL_EXTERN Result STDCALL pushStop(char *appKey, char *contentId);
// 功能:获取当前SDK版本号
// 参数:无
// 返回:版本号字符串
DLL_EXTERN const char * STDCALL getPushSdkVersion();
#ifdef __cplusplus
}
#endif
#endif