搜索结果
返回
最后更新时间: 2021-02-04 03:12:47 PM
The game developer needs to talk to the SuperSDK colleagues to open this function.
The push module provides the function of server notification.
Invoking after the successful login, the user ID is the data corresponding to the osdk_user_id returned by the SuperSDK successful login. Interface invoke:
[SuperSDK invoke:@"mobpushsdk" funcName:@"bindUser" parameters:@{
@"osdk_user_id" : @"0060015_123456" // 注意:请使用数字、字母以及下划线组成的别名,不要使用中文以及特殊字符!
}];
Message callback:
+ (void)handlerCallback:(NSString *)moduleName funcName:(NSString *)funcName parameters:(NSString *)parameters
{
NSLog(@"****** 收到回调\n moduleName : %@,\n funcName : %@,\n parameters : %@", moduleName, funcName, parameters);
NSDictionary *retParam = nil;
if (parameters) {
NSData *jsonData = [parameters dataUsingEncoding:NSUTF8StringEncoding];
if (jsonData) {
retParam = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableLeaves error:nil];
}
}
int code = [[retParam objectForKey:@"code"] intValue];
NSDictionary *data = [retParam objectForKey:@"data"];
if ([moduleName isEqualToString:@"mobpushsdk"]) {// Push模块回调
if ([funcName isEqualToString:@"receiveRemoteNotification"]) {
NSDictionary *msgInfo = [data objectForKey:@"msgInfo"]; // 推送消息
NSLog(@"收到远程推送消息,%@", msgInfo);
}
}
}
Callback log printing:
2019-05-27 16:18:11.309711+0800 SuperSDKMobUPush[4646:1893085] ****** 收到回调 ******
moduleName : mobpushsdk,
funcName : receiveRemoteNotification,
result : {
"msg":"远程通知",
"data":{
"currentServerTimestamp":0,
"content":"",
"messageID":"",
"identifier":"",
"extraInfomation":{
},
"msgInfo":{
"aps":{
"badge":1,
"alert":{
"title":"推送测试",
"body":"这是一条推送测试消息,点击此通知打开链接http://www.supersdk.cn"
},
"sound":"default"
},
"workId":"5ceb9d4277ee5d5c60683e84",
"url":"http://www.supersdk.cn", // 注意:此参数在MobPush后台设置才会存在!若不使用此功能可忽略。
"mobpushMessageId":"296317053718368256"
},
"isInstantMessage":false,
"messageType":3,
"taskDate":0
},
"code":1
}
2019-05-27 16:18:11.309961+0800 SuperSDKMobUPush[4646:1893085] 收到远程推送消息,{
aps = {
alert = {
body = "\U8fd9\U662f\U4e00\U6761\U63a8\U9001\U6d4b\U8bd5\U6d88\U606f\Uff0c\U70b9\U51fb\U6b64\U901a\U77e5\U6253\U5f00\U94fe\U63a5http://www.supersdk.cn";
title = "\U63a8\U9001\U6d4b\U8bd5";
};
badge = 1;
sound = default;
};
mobpushMessageId = 296317053718368256;
url = "http://www.supersdk.cn";
workId = 5ceb9d4277ee5d5c60683e84;
}
# Optional method
Interface invoke:
BOOL isPushStopped = [SuperSDK invokeBool:@"mobpushsdk" funcName:@"isPushStopped" parameters:nil];
if (isPushStopped) {
NSLog(@"当前远程推送关闭");
}
else {
NSLog(@"当前远程推送开启");
}
Interface invoke:
[SuperSDK invoke:@"mobpushsdk" funcName:@"restartPush" parameters:nil];
Interface invoke:
[SuperSDK invoke:@"mobpushsdk" funcName:@"stopPush" parameters:nil];
Interface invoke:
[SuperSDK invoke:@"mobpushsdk" funcName:@"clearBadge" parameters:nil];
Interface invoke:
[SuperSDK invoke:@"mobpushsdk" funcName:@"deleteUser" parameters:nil];
Set the push environment of APNs. This method is only used to test whether the remote push is correct in the development environment. Please set the production environment for non-test game packages. Important: Non-test packages must set the production environment! ! !
[SuperSDK invoke:@"mobpushsdk" funcName:@"setAPNsForProduction" parameters:@{
@"isProduction":@(YES) // 注意:非测试游戏包一定要修改成@(YES),谨记!!!
}];
The push module provides local notification function
##Add local notification
NSDateFormatter *format = [[NSDateFormatter alloc] init];
format.dateFormat = @"yyyy-MM-dd HH:mm:ss";
NSDate *fireDate = [format dateFromString:@"2019-05-27 17:15:00"];
NSTimeInterval fireInterval = [fireDate timeIntervalSince1970]*1000;
NSDictionary *parameters = @{
@"identifier":@"notificationIdentifier1", // 本地推送ID
@"alertTitle":@"通知栏显示的推送标题", // 标题
@"subTitle":@"通知栏显示的副标题", // 副标题
@"alertBody":@"通知栏显示的推送内容", // 推送内容
@"soundName":@"default.caf", // 声音文件名称
@"badge":@(1), // 角标数
@"fireDate":@(fireInterval), // 触发时间,若需立即触发,请删除此参数或直接设置当前时间戳即可
@"userInfo":@{
@"key":@"value" // 透传参数
}
};
[SuperSDK invoke:@"mobpushsdk" funcName:@"addLocalNotification" parameters:parameters];
Interface callback:
+ (void)handlerCallback:(NSString *)moduleName funcName:(NSString *)funcName parameters:(NSString *)parameters
{
NSLog(@"****** 收到回调\n moduleName : %@,\n funcName : %@,\n parameters : %@", moduleName, funcName, parameters);
NSDictionary *retParam = nil;
if (parameters) {
NSData *jsonData = [parameters dataUsingEncoding:NSUTF8StringEncoding];
if (jsonData) {
retParam = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableLeaves error:nil];
}
}
int code = [[retParam objectForKey:@"code"] intValue];
NSDictionary *data = [retParam objectForKey:@"data"];
if ([moduleName isEqualToString:@"mobpushsdk"]) {// Push模块回调
if ([funcName isEqualToString:@"addLocalNotification"]) {// 添加本地推送回调
if (code == BCORE_SUCCESS) {
NSLog(@"本地推送添加成功");
}
else {
NSLog(@"本地推送添加失败");
}
}
}
}
Log printing:
2019-05-27 17:14:30.421481+0800 SuperSDKMobUPush[4684:1903213] ****** 收到回调 ******
moduleName : mobpushsdk,
funcName : addLocalNotification,
result : {
"msg":"本地通知添加成功",
"data":{
"badge":1,
"alertTitle":"通知栏显示的推送标题",
"identifier":"notificationIdentifier1",
"soundName":"default.caf",
"alertBody":"通知栏显示的推送内容",
"subTitle":"通知栏显示的副标题",
"fireDate":1558948500000,
"userInfo":{"key":"value"}
},
"code":1
}
##Received a local notification message callback Message callback:
+ (void)handlerCallback:(NSString *)moduleName funcName:(NSString *)funcName parameters:(NSString *)parameters
{
NSLog(@"****** 收到回调\n moduleName : %@,\n funcName : %@,\n parameters : %@", moduleName, funcName, parameters);
NSDictionary *retParam = nil;
if (parameters) {
NSData *jsonData = [parameters dataUsingEncoding:NSUTF8StringEncoding];
if (jsonData) {
retParam = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableLeaves error:nil];
}
}
int code = [[retParam objectForKey:@"code"] intValue];
NSDictionary *data = [retParam objectForKey:@"data"];
if ([moduleName isEqualToString:@"mobpushsdk"]) {// Push模块回调
if ([funcName isEqualToString:@"receiveLocalNotification"]) {
NSLog(@"收到本地通知消息,%@", data);
}
}
}
Log printing:
2019-05-27 17:31:00.055549+0800 SuperSDKMobUPush[4695:1905854] ****** 收到回调 ******
moduleName : mobpushsdk,
funcName : receiveLocalNotification,
result : {
"msg":"本地通知",
"data":{
"fireDate":0,
"badge":"1",
"alertTitle":"通知栏显示的推送标题",
"identifier":"", // 此项暂时没有值!
"soundName":"", // 此项暂时没有值!
"userInfo":{"key":"value"},
"alertBody":"通知栏显示的推送内容",
"messageType":4,
"subTitle":"通知栏显示的副标题"
},
"code":1
}
##Delete local notification for the specified identifier Interface invoke:
NSDictionary * parameters = @{
@"identifier":@"notificationIdentifier1" // 本地通知标识符
};
[SuperSDK invoke:@"mobpushsdk" funcName:@"deleteLocalNotification" parameters:parameters];
##Delete all local notifications Interface invoke:
[SuperSDK invoke:@"mobpushsdk" funcName:@"deleteAllLocalNotifications" parameters:nil];