Sat*_*yam 34 iphone objective-c push-notification uialertview ios
我在我的应用中集成了推送通知.用户将收到推送通知以加入群组.当用户单击Join时,我将处理代码中的某些内容.所以我正在实施:
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
Run Code Online (Sandbox Code Playgroud)
当应用程序未运行时,此功能正常.
当应用程序运行时,我没有看到任何UIAlertView.如何让我的应用程序显示推送通知警报,以便用户仍然可以决定是否加入?
Jak*_*b W 70
我在我的应用程序委托中使用了这样的代码来模拟应用程序处于活动状态时的通知警报.您应该实现适当的UIAlertViewDelegate协议方法来处理用户点击任一按钮时发生的情况.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive) {
NSString *cancelTitle = @"Close";
NSString *showTitle = @"Show";
NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Some title"
message:message
delegate:self
cancelButtonTitle:cancelTitle
otherButtonTitles:showTitle, nil];
[alertView show];
[alertView release];
} else {
//Do stuff that you would do if the application was not active
}
}
Run Code Online (Sandbox Code Playgroud)
Avi*_*oss 17
对于任何可能感兴趣的人,我最终创建了一个自定义视图,看起来像顶部的系统推送横幅,但添加了一个关闭按钮(小蓝色X)和一个选项来点击消息进行自定义操作.它还支持在用户有时间读取/解除旧通知之前到达多个通知的情况(没有限制可以堆积多少...)
用法基本上是在线:
[AGPushNoteView showWithNotificationMessage:@"John Doe sent you a message!"];
Run Code Online (Sandbox Code Playgroud)
它在iOS7上看起来像这样(iOS6具有iOS6的外观和感觉......)

| 归档时间: |
|
| 查看次数: |
48376 次 |
| 最近记录: |