mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-22 14:02:55 +08:00
Optimize ios native methods
- setTags - setAlias - setTagsWithAlias
This commit is contained in:
parent
2a05ea1784
commit
2287ef10dd
@ -99,24 +99,45 @@
|
||||
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{
|
||||
NSString *alias = [command argumentAtIndex:0];
|
||||
NSArray *tags = [command argumentAtIndex:1];
|
||||
|
||||
[JPUSHService setTags:[NSSet setWithArray:tags]
|
||||
alias:alias
|
||||
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
|
||||
object:self];
|
||||
fetchCompletionHandle:^(int iResCode, NSSet *iTags, NSString *iAlias) {
|
||||
CDVPluginResult *result;
|
||||
if (iResCode == 0) {
|
||||
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nil];
|
||||
} else {
|
||||
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:nil];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)setTags:(CDVInvokedUrlCommand*)command{
|
||||
NSArray *tags = command.arguments;
|
||||
[JPUSHService setTags:[NSSet setWithArray:tags]
|
||||
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
|
||||
object:self];
|
||||
alias:nil
|
||||
fetchCompletionHandle:^(int iResCode, NSSet *iTags, NSString *iAlias) {
|
||||
CDVPluginResult *result;
|
||||
if (iResCode == 0) {
|
||||
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nil];
|
||||
} else {
|
||||
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:nil];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)setAlias:(CDVInvokedUrlCommand*)command{
|
||||
NSString *alias = [command argumentAtIndex:0];
|
||||
[JPUSHService setAlias:alias
|
||||
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
|
||||
object:self];
|
||||
[JPUSHService setTags:nil
|
||||
alias:alias
|
||||
fetchCompletionHandle:^(int iResCode, NSSet *iTags, NSString *iAlias) {
|
||||
CDVPluginResult *result;
|
||||
if (iResCode == 0) {
|
||||
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nil];
|
||||
} else {
|
||||
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:nil];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command{
|
||||
@ -259,9 +280,15 @@
|
||||
}
|
||||
UNNotificationCategory *category;
|
||||
if (dimiss) {
|
||||
category = [UNNotificationCategory categoryWithIdentifier:categoryId actions:actions intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
|
||||
category = [UNNotificationCategory categoryWithIdentifier:categoryId
|
||||
actions:actions
|
||||
intentIdentifiers:@[]
|
||||
options:UNNotificationCategoryOptionCustomDismissAction];
|
||||
} else {
|
||||
category = [UNNotificationCategory categoryWithIdentifier:categoryId actions:actions intentIdentifiers:@[] options:UNNotificationCategoryOptionNone];
|
||||
category = [UNNotificationCategory categoryWithIdentifier:categoryId
|
||||
actions:actions
|
||||
intentIdentifiers:@[]
|
||||
options:UNNotificationCategoryOptionNone];
|
||||
}
|
||||
[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:category]];
|
||||
}
|
||||
@ -318,16 +345,17 @@
|
||||
|
||||
#pragma mark 设置标签及别名回调
|
||||
-(void)tagsWithAliasCallback:(int)resultCode tags:(NSSet *)tags alias:(NSString *)alias {
|
||||
NSDictionary *dict = @{@"resultCode":[NSNumber numberWithInt:resultCode],
|
||||
@"tags" :tags == nil ? [NSNull null] : [tags allObjects],
|
||||
@"alias" :alias == nil ? [NSNull null] : alias
|
||||
};
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_SetTagsWithAlias jsString:[dict toJsonString]];
|
||||
if (resultCode == 0) { // Success
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- (void)networkDidReceiveMessage:(NSNotification *)notification {
|
||||
if (notification && notification.userInfo) {
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveMessage jsString:[notification.userInfo toJsonString]];
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveMessage
|
||||
jsString:[notification.userInfo toJsonString]];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user