notificationcenter

Remove push from notificationcenter after app has been opened

二次信任 提交于 2019-12-21 20:22:24
问题 When I send out a PUSH notification to my app, it stays in the notification center in iOS 5. How can I remove the notification from the notification center from within the app? 回答1: Clearing the badge clears the notifications from the notification center. - (void)applicationDidBecomeActive:(UIApplication *)application { // Clear application badge when app launches [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; } This only works if the number changes. So to make it work

Fit width in iOS 8 Today Extensions

a 夏天 提交于 2019-12-17 21:57:49
问题 When I make any iOS 8 Today Extension, there is an empty space on the left of approximately 48px, even if in Interface Builder I place a label on the left side at x=0. I have seen that some apps, however, use a full-width widget. How can I achieve something similar? Thanks! UPDATE: SOLVED I put here the sample code because I guess it will be useful to someone. As suggested by @matteo-lallone, the correct way to do this is: -(UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets

Observing Notification in Today Widget which is posted from main app

天大地大妈咪最大 提交于 2019-12-13 03:58:44
问题 I have declared notification name in a swift file which has target membership of both main app and today widget: let SpecialKey = Notification.Name("howLongNotif") Then in my main app view controller, I am posting notification when location is updated (background mode for location updates is on): NotificationCenter.default.post(name: SpecialKey, object: nil, userInfo: nil) In my today widget viewDidLoad, I am observing it like this: NotificationCenter.default.addObserver(self, selector:

Apple wallet pass not shown notification message

喜你入骨 提交于 2019-12-12 00:46:12
问题 I created an eventTicket pass for apple wallet. All working fine, passes added to Wallet, devices are register and I am able to push notification and update the passes successfully. The only problem I've got it's not showing the change message neither adding the notification to the Notification Center. This are an example of the passes pass.json: First pass sent { "formatVersion" : 1, "passTypeIdentifier": "pass.code.paq.test", "serialNumber": "14", "teamIdentifier": "TE4545WNZ9",

Receiving meaningful notifications from other apps and NotificationCenter

懵懂的女人 提交于 2019-12-11 16:23:09
问题 I want to receive notifications from other applications that would appear on lock screen- similar to how Pebble and other smart watches receive them. It is easy to register for notifications via NSNotificationCenter.defaultCenter().addObserver(self, selector: "receiveNotification:", name: nil, object: nil) But then the app receives loads of notifications, most of which are relatively meaningless (cache changes, state changes, UI changes, etc). What would be the best way to filter only those

Issue while handle user typing notification using notificatincenter

时光总嘲笑我的痴心妄想 提交于 2019-12-11 04:22:34
问题 I am creating an chat application using socket.io, every things going perfect but when I am handling user typing notification I am getting error like below Error: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SocketChat.ChatViewController handleUserTypingNotification:]: unrecognized selector sent to instance 0x7f817653d710 and now I will show you my code for better expiation Code: private func listenForOtherMessages() { socket.on("userTypingUpdate") {

Notifications causing no dealloc to be called

戏子无情 提交于 2019-12-11 03:38:01
问题 I am trying to use this within a project: https://github.com/zakkhoyt/VWWPermissionKit I do not understand KVO/Notification Center as much as I'd like so posting a question. Basically the init and dealloc for the Permission Manager look like this: - (instancetype)init { self = [super init]; if (self) { [[NSNotificationCenter defaultCenter] addObserverForName:VWWPermissionNotificationsPromptAction object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { dispatch_async

Passing parameters with #selector

这一生的挚爱 提交于 2019-12-10 17:37:51
问题 I'm a beginner to Swift and I'm trying to initiate a function through NotificationCenter. The observer in 'ViewController.swift' calls on function reload : override func viewDidLoad() { super.viewDidLoad() NotificationCenter.default.addObserver(self, selector: #selector(reload), name: NSNotification.Name(rawValue: "reload"), object: nil) } func reload(target: Item) { print(target.name) print(target.iconName) } ... which has a parameter of class Ítem : class Item: NSObject { let name: String

In what situation would one use expectationForNotification in swift testing

微笑、不失礼 提交于 2019-12-10 01:54:58
问题 I'm a little confused as what/when to do with expectationForNotification as opposed to expectationWithDescription`. I've been unable to find any clear examples in swift for when and what you do with this call. I'm assuming its perhaps to test notifications but it looks like it might just be a more convenient wrapper around the whole addObserver() call of notification center. Could somebody give a brief explanation of what it does, when to use it, and perhaps a few lines of sample code? 回答1:

Stopping notification bar to popup during game play

吃可爱长大的小学妹 提交于 2019-12-09 13:07:30
问题 Context: I am working on a windows phone game using XNA 4.0 framework. During the gameplay, if the user accidentally drags the top of screen, notification center gets dragged down. I have seen few apps where this behaviour is overridden and instead of notification center popping up, a small cue is shown at the top as shown in the screenshot below. Question: What is the API that stops notification center to come up when user accidentally drags the top of screen during gameplay? Screenshot of