Important: Please delete the third-party push SDK and related API interfaces added in the original game before access to prevent conflicts and crashes!
Push module provides remote push notification and local push notification functions.
Game needs to first contact SuperSDK personnel to enable this function and apply for relevant parameters.
Note: If this interface is called after a successful login, the user ID is the osdk_user_id value returned by SuperSDK.
Interface Call:
[SuperSDK invoke:@"mobpushsdk" funcName:@"bindUser" parameters:@{
@"osdk_user_id" : @"0060015_123456" // Note: Please use aliases consisting of numbers, letters and underscores. Do not use Chinese or special characters!
}];
Logout Callback:
+ (void)handlerCallback:(NSString *)moduleName funcName:(NSString *)funcName parameters:(NSString *)parameters
{
NSLog(@"****** Received Callback\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 module callback
if ([funcName isEqualToString:@"receiveRemoteNotification"]) {
NSDictionary *msgInfo = [data objectForKey:@"msgInfo"]; // Push notification
NSLog(@"Received remote push notification, %@", msgInfo);
}
}
}
Log Print:
2019-05-27 16:18:11.309711+0800 SuperSDKMobUPush[4646:1893085] ****** Received Callback ******
moduleName : mobpushsdk,
funcName : receiveRemoteNotification,
result : {
"msg":"Remote Notification",
"data":{
"currentServerTimestamp":0,
"content":"",
"messageID":"",
"identifier":"",
"extraInfomation":{
},
"msgInfo":{
"aps":{
"badge":1,
"alert":{
"title":"Push Test",
"body":"This is a push notification test. Click this notification to open the link http://www.supersdk.cn"
},
"sound":"default"
},
"workId":"5ceb9d4277ee5d5c60683e84",
"url":"http://www.supersdk.cn", // Note: This parameter only exists in MobPush backend settings! If you do not use this function, ignore it.
"mobpushMessageId":"296317053718368256"
},
"isInstantMessage":false,
"messageType":3,
"taskDate":0
},
"code":1
}
2019-05-27 16:18:11.309961+0800 SuperSDKMobUPush[4646:1893085] Received remote push notification, {
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;
}
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; // Note: In milliseconds
NSDictionary *parameters = @{
@"identifier":@"notificationIdentifier1", // Local push ID
@"alertTitle":@"Push title displayed in notification bar", // Title
@"subTitle":@"Push subtitle displayed in notification bar", // Subtitle
@"alertBody":@"Push content displayed in notification bar", // Push content
@"soundName":@"default.caf", // Sound file name
@"badge":@(1), // Badge count
@"fireDate":@(fireInterval), // Trigger time, if needs to trigger immediately, delete this parameter or directly set as current timestamp
@"userInfo":@{
@"key":@"value" // Passthrough parameter
}
};
[SuperSDK invoke:@"mobpushsdk" funcName:@"addLocalNotification" parameters:parameters];
Interface Callback:
+ (void)handlerCallback:(NSString *)moduleName funcName:(NSString *)funcName parameters:(NSString *)parameters
{
NSLog(@"****** Received Callback\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 module callback
if ([funcName isEqualToString:@"addLocalNotification"]) {// Add local push callback
if (code == BCORE_SUCCESS) {
NSLog(@"Local push added successfully");
}
else {
NSLog(@"Failed to add local push");
}
}
}
}
Log Print:
2019-05-27 17:14:30.421481+0800 SuperSDKMobUPush[4684:1903213] ****** Received Callback ******
moduleName : mobpushsdk,
funcName : addLocalNotification,
result : {
"msg":"Local push added successfully",
"data":{
"badge":1,
"alertTitle":"Push title displayed in notification bar",
"identifier":"notificationIdentifier1",
"soundName":"default.caf",
"alertBody":"Push content displayed in notification bar",
"subTitle":"Push subtitle displayed in notification bar",
"fireDate":1558948500000,
"userInfo":{"key":"value"}
},
"code":1
}
Logout Callback:
+ (void)handlerCallback:(NSString *)moduleName funcName:(NSString *)funcName parameters:(NSString *)parameters
{
NSLog(@"****** Received Callback\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 module callback
if ([funcName isEqualToString:@"receiveLocalNotification"]) {
NSLog(@"Received local push notification,%@", data);
}
}
}
Log Print:
2019-05-27 17:31:00.055549+0800 SuperSDKMobUPush[4695:1905854] ****** Received Callback ******
moduleName : mobpushsdk,
funcName : receiveLocalNotification,
result : {
"msg":"Local Notification",
"data":{
"fireDate":0,
"badge":"1",
"alertTitle":"Push title displayed in notification bar",
"identifier":"", // This item has no value!
"soundName":"", // This item has no value!
"userInfo":{"key":"value"},
"alertBody":"Push content displayed in notification bar",
"messageType":4,
"subTitle":"Push subtitle displayed in notification bar"
},
"code":1
}
Interface Call:
NSDictionary * parameters = @{
@"identifier":@"notificationIdentifier1" // Local notification identifier
};
[SuperSDK invoke:@"mobpushsdk" funcName:@"deleteLocalNotification" parameters:parameters];
Interface Call:
[SuperSDK invoke:@"mobpushsdk" funcName:@"deleteAllLocalNotifications" parameters:nil];