我目前正在通过Pushbots插件向我的Phonegap应用发送推送通知。但是通过初始设置,消息将显示为横幅(仅在顶部,没有打开/关闭按钮)。我想把它显示为警报!这可能吗?
如何以编程方式更改内容?
这是pushbots插件的ObjC代码:
#import "PushbotsPlugin.h"
@implementation PushbotsPlugin
- (void)initializeWithAppId:(CDVInvokedUrlCommand*)command {
[self.commandDelegate runInBackground:^{
CDVPluginResult* pluginResult = nil;
NSString* appId = [command.arguments objectAtIndex:0];
dispatch_async(dispatch_get_main_queue(), ^{
[Pushbots sharedInstanceWithAppId:appId];
});
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
- (void) setAlias:(CDVInvokedUrlCommand *)command
{
NSLog(@"Executing setAlias(Alias)");
CDVPluginResult* pluginResult = nil;
NSString* alias = [command.arguments objectAtIndex:0];
[[Pushbots sharedInstance] sendAlias:alias];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void) debug:(CDVInvokedUrlCommand *)command
{
NSLog(@"Executing debug(debug)");
CDVPluginResult* pluginResult = nil;
BOOL debug = [[command.arguments objectAtIndex:0] isEqual:[NSNumber numberWithInt:1]];
[[Pushbots sharedInstance] debug:debug];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void) tag:(CDVInvokedUrlCommand *)command
{
NSLog(@"Executing tag(Tag)");
CDVPluginResult* pluginResult = nil;
NSString* tag = [command.arguments objectAtIndex:0];
[[Pushbots sharedInstance] tag:tag];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void) getToken:(CDVInvokedUrlCommand *)command
{
NSLog(@"Executing getToken()");
CDVPluginResult* pluginResult = nil;
NSString* deviceId = [[Pushbots sharedInstance] getDeviceID];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:deviceId];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void) untag:(CDVInvokedUrlCommand *)command
{
NSLog(@"Executing untag(Tag)");
CDVPluginResult* pluginResult = nil;
NSString* tag = [command.arguments objectAtIndex:0];
[[Pushbots sharedInstance] untag:tag];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void) resetBadge:(CDVInvokedUrlCommand *)command
{
[self.commandDelegate runInBackground:^{
CDVPluginResult* pluginResult = nil;
dispatch_async(dispatch_get_main_queue(), ^{
[[Pushbots sharedInstance] clearBadgeCount];
});
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
- (void) unregister:(CDVInvokedUrlCommand *)command
{
[self.commandDelegate runInBackground:^{
CDVPluginResult* pluginResult = nil;
dispatch_async(dispatch_get_main_queue(), ^{
[[Pushbots sharedInstance] unregister];
});
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
- (void) setBadge:(CDVInvokedUrlCommand *)command
{
NSLog(@"Executing setBadge(count)");
CDVPluginResult* pluginResult = nil;
NSString* count = [command.arguments objectAtIndex:0];
int badge = [count intValue];
[[Pushbots sharedInstance] setBadge:badge];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
@end
答案 0 :(得分:1)
据我所知,无法以编程方式将横幅通知更改为应用外的警报通知。即使你这样做也没有。
用户必须进入设置>通知>你的应用>选择"提醒"而不是"横幅"。
没有别的办法,抱歉:(