当我的应用程序处于后台 iOS 时,如何获得通知

问题描述

我有一个游戏应用程序,它使用蓝牙在两个 iOS 设备之间来回发送移动。一个人可以发出邀请让其他玩家玩,然后如果他们想玩,他们可以肯定地回应。
我目前正在使用 UIAlertController 当前显示邀请和响应,但它仅在应用程序处于前台时才有效。我想这样做,当应用程序在后台时,它仍然在侦听邀请,并在有人到达时显示邀请,即使在后台也是如此。

这是当应用程序在前台时我用来获取邀请的代码

if ([region.identifier isEqualToString:@"com.checkers.bluetooth"]) {
                    
                   [UIView animateWithDuration:1 delay:0 options:UIViewAnimationoptionCurveEaseIn animations:^{
                        
                       
                        
                    } completion:^ (BOOL completed) {}         ];
                   
                    AlertView = [UIAlertController
                                    alertControllerWithTitle:NSLocalizedString(@"PLAYGAME",nil)
                                 message: NSLocalizedString(@"PLAYCHECKERS",nil)
                                              preferredStyle:UIAlertControllerStyleAlert];

                    UIAlertAction* okButton = [UIAlertAction
                                        actionWithTitle:@"OK"
                                                  style:UIAlertActionStyleDefault
                                                handler:^(UIAlertAction * action) {
Do things
                              }];

                    UIAlertAction* cancelButton = [UIAlertAction
                                            actionWithTitle:@"CANCEL"
                                                      style:UIAlertActionStyleDefault
                                                    handler:^(UIAlertAction * action) {
do other things
                        }];

                    [AlertView addAction:okButton];
                    [AlertView addAction:cancelButton];


                    [self presentViewController:AlertView animated:YES completion:nil];

有人可以帮我解决这个问题吗?我让它与 UIlocalnotifications 一起工作,但已被弃用。所以我被卡住了。
我将不胜感激教程或示例。我正在使用objective-c。
谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...