iOS MVC - What if model needs additional information from user? - ios

In my iOS app, there is a condition under which I'd like the user to confirm that he wants to receive remote notifications if he hasn't already, then perform the registration (using registerUserNotificationSettings before iOS 10 or requestAuthorizationWithOptions / registerUserNotificationSettings for iOS 10+). The model will then send the device token back to my server when it requests more data.
I'm trying to use a "clean" MVC pattern. Is the following considered a best practice for when the model needs additional information from the user?
The model determines the condition for remote notifications has been satisfied and determines the user hasn't confirmed wanting remote notifications.
The model calls a method on the view controller (as a delegate) to ask the user to confirm wanting remote notifications.
Since the confirmation process happens asynchronously, the view controller then calls a method on the model with the result.
If the user confirmed, the model registers the user and handles the result. This will involve interaction between the model and app delegate, and iOS may display its own confirmation modal to the user which is ok.
An alternative would be for the model to pass a completion handler to the view controller in step 2, which is passed around and finally executed by the view controller when result is obtained. (A little tricky with UIAlertView before iOS 9 but pretty easy with UIAlertController for iOS 9+.)
Thanks for any thoughts!

Related

Beginner Firebase User FCM Set-Up Questions

FOR iOS
Notifications
Cannot see an option for in app pop up messsages - is it only push/re-engagement message types?
Can the notifcations be automated not just scheduled one by one? Can this be done programatically? I.e. Something left in basket so send automatic push
Can the notifications be triggered based on in app user behaviour not just audience or property and can they have a time lag e.g. 3 days after trigger? I.e. User clicked on X promotion and hasn't returned in 2 days
Active Users 1, 7, 30 day
Accuracy of data - how reliable is the Firebase Active user data - what is the definition of actives reported?
Viewing new vs returning? Is this possible? I cannot find a view of this in the dashboard?
User Properties
When you add the code for the setUserProperty() once is is registered how does Firebase start to gather than data on this user property value?
Cannot see an option for in app pop up messsages - is it only
push/re-engagement message types?
FCM is for Notifications and data messages. At this time, if you want messages to appear in the app, you would use a data payload and handle the appearance of a pop-up within your code. See About FCM Messages for details on Notifications vs data messages.
Can the notifcations be automated not just scheduled one by one? Can
this be done programatically? I.e. Something left in basket so send
automatic push
From the console, you can schedule notifications. If you want to automate based on events, I suggest you use a combination of Cloud Functions for Firebase and the Admin SDK. Store the FCM tokens in the database for sending.
Can the notifications be triggered based on in app user behaviour not
just audience or property and can they have a time lag e.g. 3 days
after trigger? I.e. User clicked on X promotion and hasn't returned in
2 days
As for a delay, that would be something you'd have to handle in your own server.
Accuracy of data - how reliable is the Firebase Active user data -
what is the definition of actives reported?
According to the documentation, "An active user has engaged with an app in the device foreground, and has logged a user_engagement event."
Viewing new vs returning? Is this possible? I cannot find a view of
this in the dashboard?
No, this is not possible. You can see the first_open event and extrapolate from that.
When you add the code for the setUserProperty() once is is registered
how does Firebase start to gather than data on this user property
value?
According to the documentation, "User properties are effectively sticky event parameters that are automatically logged when you call logEvent."

Notifications with SignalR2 and MVC

I want to build a menu notification with SignalR 2 in my MVC app.
So, when some user do a specific action, some others users (not all and not the same every time) must be notified. Some like the SO notification when somebody answer a question.
Do I should store the connectionId in a database to know who must be notified after the action is triggered? What would you do?
I had to do something similar and this is what I did:
1) Define notification types based on user roles. Each notification type had a list of specific recipients. That way I knew if a notification type was created I had to notify certain users.
2) I send the notifications by name, not by connection id.
3) Notifications can be sent from client code (JS) or from back-end code (C#). In JS you have functions like "others" that are really handy. In C# you have "others" too but that only works with connection ids.
4) I'm notifying changes in the data too so if someone is changing order 1, I notify a supervisor and any other user that has the order opened (in this case I send the notification to the supervisor and all the other agents and based on the order each user has opened I decide if I handle the msg or not).
I hope this helps!

Send and Receive bluetooth data at the same time in iOS

I am creating an iOS application which needs to send and receive data at the same time while being in one viewController rather than a CentralView and a PeripheralView. Is this possible? I have been using apple's sample code for bluetooth but I can only get half the data I need from that. How can I send and receive data from bluetooth simultaneously while in one viewController?
API is asynchronous so there is no problem
view controller should not do it. Write some class/service which will be manged by view controller, its life time should be different than view controller (depending on application).

ios, Is there a change in push notification authorization callback

In ios, if I authorize or reject Location Services when prompted, there is a delegate method that gets called immediately:
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status;
I'm wondering if a similar method exists for accepting or rejecting Push Notifications. I'm aware of how to prompt, as well as how to test for status, but not how to do something immediately after a user accepts or rejects the notification.
I would like to prompt the user for Push Notification, and based on their response do a certain action, such as redirect the ViewController one way or another.
I've done a great deal of research on this and - unfortunately - the status of that accept/decline option appears to be entirely opaque.
You can determine that the user doesn't have push notifications enabled (using UIApplication's isRegisteredForRemoteNotifications), but not why it isn't enabled (ie. determine whether it's a "never prompted" or "prompted and then declined or later disabled" state).
I strongly suspect that this was a conscious design decision by Apple to make it more difficult for developers to hound users who've opted out. There are legitimate reasons to have this information, though, so I hope in the future they reconsider.
I hope this helps.
You can not do that but you can check that every time the app gets into foreground. This would solve your case when you can take action at the moment the user opens the app.
If you want to do that on background (in case you want to report your server that user has been disabled notification for example) you can always run some background task (like "Background fetch") to check the status.

Call duration class

I'm looking for the class that handles call duration UIView ( Or caller name ) for iOS 8
, So i could hook into it and find its frame position
What i tried and found so far :
I looked up the TelephonyUI private framework headers classes and Found nothing after so many hours of digging and trying
Sounds to me that it's related to MobilePhone.app but couldn't also find anything
syslog mostly logs data from it under Core Telephony Framework
On iOS 8 the in call UI no longers runs in MobilePhone or SpringBoard. It actually runs in a separate process - InCallService.app. It's works just like MFMessageComposeViewController I researched here. MobilePhone or SpringBoard (don't know for sure and it doesn't really matter), displays, what is called, remote view controller for in call view - it's a view controller which is being displayed in your app but the actual logic behind it runs in a separate process.
For example, when you display MFMessageComposeViewController to send SMS message from your app you actualy using proxy object which connects through XPC to another process where actual view controller code runs. Your app only sends user input to the process and displays results that it returns to you - remote view controller forwards method calls through XPC connection. You don't actually have any control over the controller - you can manipulate it through a very limited API provided by XPC service that implements the logic.
Obvious purpose of these remote view controllers is security. On iOS 5 there wasn't any and MFMessageComposeViewController was implemented just like a regular view controller. It meant that you could reverse engineer it to send SMS messages without user permission. And that exactly what some people did - there was AppStore apps that could send SMS messages silently using this code. Starting at iOS 6 that code requires special entitlement that AppStore can't have. MessagesViewService.app has it and through remote view controller running in it you can send SMS messages from AppStore apps but now you can't do it without the UI and user interaction.
Same with in call UI. You can test it by doing a call and then killing InCallService.app process - in call view will disappear. So in order to change something you need to hook InCallService.app. Unfortunatelly I didn't research it to tell you exactly which methods you need to hook but at this point it will be very easy. I suggest you start looking at PHInCallRootViewController, PHInCallRootViewControllerActual and PHCallParticipantsView. The latter has a very interesting method setSingleDurationTimerLabel:(id) which modifies _singleDurationTimerLabel ivar. It looks like duration label view.

Resources