Tag: 通知中心

苹果钱包通过不显示通知消息

我为苹果钱包创build了一个eventTicket通行证。 所有工作正常,通过添加到电子钱包,设备注册,我能够推送通知,并成功地更新通行证。 唯一的问题是,它没有显示更改消息,也没有将通知添加到通知中心。 这是pass pass.json的一个例子: 第一关发送 { "formatVersion" : 1, "passTypeIdentifier": "pass.code.paq.test", "serialNumber": "14", "teamIdentifier": "TE4545WNZ9", "webServiceURL": "https://testdomain/applewallet/deviceservice/", "authenticationToken": "2344e35c-c348-345c-945b-32bce234bc12", "organizationName" : "Test" "description" : "testpass", "foregroundColor" : "rgb(255, 255, 255)", "eventTicket": { "primaryFields": [ { "key": "member", "label": "MEMBER NAME", "value": "John Smith" } ], "secondaryFields": [ { "key": "level", "label": "LEVEL", "value": "Black", […]

iOS – NotificationCenter addObserver“UIMenuControllerWillHideMenu”

我已经为UIMenuControllerWillHideMenu添加了通知观察者,但是它不会调用添加/关联通知中心的select器。 UIMenuControllerWillHideMenu是UIMenuControllerWillHideMenu的通知中心标识符,应该在UIMenuController隐藏时UIMenuController 。 但不知何故,这是行不通的。 这里是我试过的代码(Swift 3.x): private func addMenuObserverNotification(){ NotificationCenter.default.addObserver(self, selector: #selector(self.menuControllerWillHideMenu), name: NSNotification.Name(rawValue: "UIMenuControllerWillHideMenu"), object: nil) } // This function should be called on 'UIMenuControllerWillHideMenu' func menuControllerWillHideMenu() -> Void { removeMenuObserverNotification() } private func removeMenuObserverNotification(){ NotificationCenter.default.removeObserver(self) } 无法识别,什么是错的。

通知不会导致dealloc被调用

我想在一个项目中使用这个: https : //github.com/zakkhoyt/VWWPermissionKit 我不太了解KVO /通知中心,所以我想发表一个问题。 基本上,Permission Manager的init和dealloc如下所示: – (instancetype)init { self = [super init]; if (self) { [[NSNotificationCenter defaultCenter] addObserverForName:VWWPermissionNotificationsPromptAction object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { dispatch_async(dispatch_get_main_queue(), ^{ VWWPermission *permission = note.userInfo[VWWPermissionNotificationsPermissionKey]; [permission presentSystemPromtWithCompletionBlock:^{ dispatch_async(dispatch_get_main_queue(), ^{ [permission updatePermissionStatus]; if(permission.status == VWWPermissionStatusDenied){ [self.permissionsViewController displayDeniedAlertForPermission:permission]; } [self checkAllPermissionsSatisfied]; }); }]; }); }]; [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil […]

如何在今日扩展中从资产目录中展示图片?

我正在为iOS8的今天扩展工作。 我的应用程序组设置正确,我可以成功地使用NSUserDefaults发送简单的数据到我的扩展(使用本教程 )。 在我的扩展的故事板中,我将一个图像放置在故事板上,并将图像设置为资产目录中的资产。 即使它出现在Interface Builder中,当我在设备和模拟器上运行应用程序时,图像也不会显示。 我错过了什么?

NotificationCenter swift3无法观察post

我有3个通知: NotificationCenter.default.post(name:NSNotification.Name("Notification1"), object: nil) NotificationCenter.default.post(name:NSNotification.Name("Notification2"), object: nil) NotificationCenter.default.post(name:NSNotification.Name("Notification3"), object: nil) 我在视图控制器中为每个post分配一个不同的观察者 第一个 : NotificationCenter.default.addObserver(forName:NSNotification.Name("Notification1"), object: nil, queue: nil, using: updateUx) 第二种 : NotificationCenter.default.addObserver(forName:NSNotification.Name("Notification2"), object: nil, queue: nil, using: updateUx) 第三 : NotificationCenter.default.addObserver(forName:NSNotification.Name("Notification3"), object: nil, queue: nil, using: updateUx) updateUx函数只包含一个通知的打印。 我只有我的第一个通知,我不能赶上另外两个,我不知道为什么。

下次启动应用程序时,我可以解除本地通知吗?

我知道当用户在通知中心点击此通知时,我可以取消通知。 但是我可以在其他地方取消通知,我无法从系统获得相关的本地通知。 我可以序列化本地通知,并在下次运行应用程序时取消它? 对不起,让你误会! 我想在通知中心解散已发布的通知,但不是预定的通知。 所以我想问的是如何保存本地通知对象,然后我可以使用它在下次启动应用程序时自行解除。 也许这个工作不能用现在的SDK来完成。

通知中心的图片预览

是否有可能将图像添加到推送通知的有效载荷? 我已经看到它正在照片和消息应用程序中完成。 我希望这不是一些私人的苹果API。 下面的屏幕截图是在运行iOS 6的设备上拍摄的。

Swift NSNotificationCenter?

我试图让UITextViewTextDidChangeNotification工作。 我是使用NSNotificationCenter的新手,所以我很难理解到底发生了什么。 我在故事板中有一个UITextView,并且在ViewController类中为它创build了一个IBOutlet,并将其命名为textView。 这是我的viewDidLoad函数: override func viewDidLoad() { super.viewDidLoad() origin = self.view.frame.origin.y if let field = textView{ field.placeholder = placeholder field.layer.cornerRadius = 8 field.layer.borderWidth = 0.5 field.layer.borderColor = UIColor.grayColor().CGColor NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyPressed:"), name:UITextFieldTextDidChangeNotification, object: nil); } NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name:UIKeyboardWillShowNotification, object: nil); NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name:UIKeyboardWillHideNotification, object: nil); } 键盘通知很好用。 据我了解,他们调用与select器相同的名称的函数。 那是对的吗? 还是有更多的事情在这里? 我做了一个叫做keyPressed的函数,它把一个NSNotification作为参数,但是这个函数从来没有被调用,而当我使用键盘的时候,keyboardWillShow和keyboardWillHide函数被调用。 有人可以解释发生了什么事吗?

iOS推送其他应用程序的通知

有没有办法接收所有应用程序的推送通知? 那么所有通知都显示在通知中心? 如果是,当收到任何应用程序的推送通知时,是否也可以执行一个操作? 谢谢 编辑:如果应用程序将被苹果公司接受并不重要。

在iOS 8的今天扩展适合宽度

当我制作任何iOS 8 Today扩展时,即使在Interface Builder中我在x = 0的左侧放置了一个标签,左边的空白区域大约为48px。 我已经看到,有些应用程序使用全宽度小部件。 我怎样才能达到类似的东西? 谢谢! 更新:解决 我把这个示例代码放在这里,因为我猜这对别人有用。 正如@ matteo-lallone所build议的,正确的做法是: -(UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMa‌​rginInsets{ return UIEdgeInsetsZero; }