Comments (9)
So you want a dictionary property added to each instance of the message view?
Perhaps I'm misunderstanding the need, but model/payload information shouldn't be included in any view-specific classes; basic MVC.
Model-specific logic can exist outside the "show" call and be referenced within the tap callback. Wouldn't this suffice?
from twmessagebarmanager.
I'd be interested in hearing more about the use case here; I suspect there's another way to solve your problem without adding model state to this view.
(For sake of argument, I've been trying for a few minutes to come up with a UIKit API that might provide some sort of precedent for this pattern, but I can't think of any.)
from twmessagebarmanager.
I think the use-case is quite standard for moderately complex apps. A push notification is received and processed, while the app is active. The user may or may not want to respond. So we toss out a notice. If the user taps it, we know they are engaging, thus we must act on the payload provided by the original push. I suspect a simple __block dictionary will manage this process. I think i was getting confused between reviewing a bunch of libraries today and had this one mixed with another that centralized responses rather than a local block.
So.. __block the payload dictionary, await the engagement and with the code block use the __block variable.. sound about right? (i am a moderate newbie to this platform)
from twmessagebarmanager.
To re-iterate, model and view should remain mutually exclusive.
A MVC solution:
appDidReceiveRemoteNotification:(id)notification...{
id payload = notification.payload;
if (payload.notificationType == type1){
[[TWMessageBarManager sharedInstance] show... callback:{
// user clicked - we have all info we need from the payload
[self presentViewOfType:type1 withPayload:payload];
}];
}
}
from twmessagebarmanager.
thanks terry, similar to what i described after i explained my brain-fart earlier. Only diff is that i was under the assumption only __block vars are accessible inside of callback blocks?
from twmessagebarmanager.
@wdcurry correct, so just declare a few __block vars prior to presenting the message:
_block NSDictionary *payloadBlock = notification.payload;
from twmessagebarmanager.
Only diff is that i was under the assumption only __block vars are accessible inside of callback blocks?
No, __block
doesn't have anything to do with accessibility. You can capture variables inside callback blocks without any special notation. See this Stack Overflow answer for some additional explanation.
from twmessagebarmanager.
thanks kindly cd.. i enjoy learning something new every day ;)
from twmessagebarmanager.
i enjoy learning something new every day ;)
As do I 😄
from twmessagebarmanager.
Related Issues (20)
- Carthage Support
- Banner hidden by iPhone X notch
- Messages go above navigation bar (iOS 14)
- When there is SceneDelegate in app then it won't showing TWMessageBar
- Turn png images to code using PaintCode HOT 1
- Customization HOT 6
- Dismiss via swipe HOT 3
- Text is vertically not centered HOT 1
- Vertically align label with icon when description == nil or title == no HOT 1
- Swift support? HOT 1
- description not align icon HOT 1
- Swift Project HOT 2
- Some change to your project. HOT 1
- Allow to setup windowLevel
- use_frameworks! HOT 4
- Banner does not show in case of multiple push notification. HOT 1
- callback block not executed HOT 6
- Issue - Alert bellow status bar in iOS 9/10 HOT 1
- Customize TWMessageView numerics
- Do not hide, keep the popup unless until user taps on it? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twmessagebarmanager.