Firebase overwrite default screen name - ios

I'm using the Firebase SDK and I want to give everyscreen a custom name so that I can track this.
Now when the app starts I get this info statement:
Firebase automatic screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name
Now I don't see where I can just overwrite the default screen name, is it a property somewhere on every viewcontroller?

If you would like to overwrite it, then I'd recommend to use the method in viewDidAppear in each of your view controller. To avoid conflicting reporting with the auto reporter as it might overwrite your own screen name, I think you might want to turn off the auto reporter:
To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO in the Info.plist

Related

UNNotificationContentExtension not displaying

I'm trying to make a custom notification alert. I added my extension target and changed the UNNotificationExtensionCategory value to 'drawing'.
In my push notification I added a "category" : "drawing" element to the aps block. The didReceive(_:) method from that extension is never getting called though. What did I forget to do?
You seem to have done whats needed. I too had similar problem of not seeing the custom notification screen.
However, whats not mentioned in the documents of UNNotificationContentExtension is that the custom screen appears only when you do a 3D touch on the notification alert. I tried to do a 3D touch and the custom screen appeared. Please check.
First check that the extension category is set appropriately in the extension info.plist file to match what is being sent in the aps block of your push notification
Second check that the deployment target for the extension is <= to the iOS version of the device you're trying to run on.
Have u added this in your target's info.plist file instead of ACTIONABLE add drawing
I had similar issue, it was just that in the plist I made my UNNotificationExtensionCategory to be an Array and I wasn't adding them correctly.
Incorrect:
It shouldn't come next to UNNotificationExtensionCategory ie it shouldn't be a field of NSExtensionAttributes
Correct:
It should be a field of UNNotificationExtensionCategory
Apparently to learn how to use the plist you need at least 25 years of experience :)
This method is only called once you force touch into the notification.
If you are monitoring this through LLDB, it runs as a separate process. Make sure you're building your extension target in order to access these methods and the logs from LLDB.
Lastly, if you are like me, and you have discarded the storyboard, then you need to specify the principal class in your extensions Info.plist. This class must be your main view controller including the target namespace. For example, if your extension is MyNotificationExtension then you would set NSExtension > NSPrincipalClass to MyNotificationExtension.MyNotificationExtensionViewController.

Objective-C | Watch property and get notified about change incl. location of change

I'm trying to find out why my UITableView changes the width (bigger than phone-screen). Therefore I tried to use KVO, but observeValueForKeyPath:ofObject:change:context: isn't delivering me the information about the place where the property got changed.
I also tried to set a breakpoint and follow the call stack, to see the place of change - without success - maybe it's happening in another thread.
Does anybody know how to watch a property and get the location of change?

Font size change section footer table view

I'm currently building an iOS App in Swift and I got some problems. My settings view is a tableviewcontroller. It's a grouped one. My Table View is dynamic, fonts are dynamics.
I would like to interact to the change of font size from the settings app.
If my application was already running, the font size change but the layout is just broken. (change from the smallest to the biggest font)
Image : Layout bug
If I restart my app with the new font settings, there is no problems...
Here is a XCODE project example, you'll see the bug.
Could you please help me to find a solution ? Thanks.
The UIContentSizeCategoryDidChangeNotification is what you're looking for.
Per the docs:
Posted when the user changes the preferred content size setting.
This notification is sent when the value in the
preferredContentSizeCategory property changes. The userInfo dictionary
of the notification contains the UIContentSizeCategoryNewValueKey key,
which reflects the new setting.
Example callback implementation:
func handleContentSizeCategoryDidChangeNotification(notification: NSNotification) {
self.questionLabel.font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)
}
After you change the font size try to call
self.view.setNeedsLayout()
it sets a flag in the UIView that marks it as needing layout change.
Also you can try to call
self.view.layoutIfNeeded()
Apple documentation says :
Use this method to force the layout of subviews before drawing. Using the view that receives the message as the root view, this method lays out the view subtree starting at the root.
Hope that help you
Finally, I found that it's an iOS bug. I find the same bug in the Apple Apps.
The bug happens when you set the smallest font, quit the app and set the biggest font.
Thanks for your help.
Bug Settings App

Correct way to display today view widget content

I'm working on a today view extension with some custom view elements which I don't set up in interface builder.
Now I'm wondering where the right point in the lifecycle is to init the widget content.
I read about updating the content in widgetPerformUpdateWithCompletionHandler so I implemented a check for new updates which should about the view.
But my observations showed me that the method is called before viewDidAppearand so there is no view to update.
Also I tought the widget stays in memory for a while so that I can have a certain object in widgetPerformUpdateWithCompletionHandler whose content I can update and use in viewDidAppear but this isn't the case (it loads every time)
So what is the correct way: write content to disk in the widgetPerformUpdateWithCompletionHandler, can I depend on something that is in memory or just ignore and refresh on every load?
In TodayViewController.m -viewDidLoad() method is called each time you open notification. So when ever you check Today widget it will call -viewDidLoad(). So you do your customisation in -viewDidLoad(). Unless you don't want to check previous state.
Straight from a blog which helps a create Today widget with real time data:
Creating today widget
Caching
We can take advantage of NSUserDefaults to save the calculated used space between launches. The lifecycle of a widget is short so if we cache this value, we can set up the user interface with an initial value and then calculate the actual value.
Edit:
From Apple documentation it state that
To help your widget look up to date, the system occasionally captures snapshots of your widget’s view. When the widget becomes visible again, the most recent snapshot is displayed until the system replaces it with a live version of the view.
It is also state that from Notification center, We can get widget details of state and snapshot.
Not sure with this, but it state that below method is used by both widget and containing app to check its content. There is no much details about how to get widget snapshot.
func setHasContent(_ flag: Bool,
forWidgetWithBundleIdentifier bundleID: String!)
NCWidgetController setHasContent
Edit 2: Use of NSUserDefaults in extension:
You have two .entitlements files, one for host app and second for the extension app, add below key in both files
<key>com.apple.security.application-groups</key>
<array>
<string>group.YourExtension</string>
</array>
You see the value for key is group.YourExtension it is shared
common key for both host app and extension app
Save your data using group.YourExtension in NSUserDefaults

Would it be OK to add a custom button on a system keyboard in iPad

I have a requirement wherein I have to change the text of the return key of the iPad to Sign-in. Obviously it is not one of the options available in the sdk. I have searched it over the net and it seems doing that possible.
The only question remaining is whether the app would be accepted by Apple if I modify the default system keyboard? The HIG is not clear on this , it states that "A custom input view can replace the system-provided onscreen keyboard in apps" and "You can also provide a custom input accessory view, which is a separate view that appears above the keyboard (or your custom input view)". Nothing about whether we are allowed to add an extra button on a system keyboard.
Any experiences??
#Vin you can change the name of return key of the keyboard to your requirement. I have an app that has the changed to return key name to Done and Search. And apple did not reject it.
To "Sign-In" you can use the return key UIReturnKeyJoin
textField.returnKeyType = UIReturnKeyJoin;
EDIT
Nope. You get the return key and
keyboard types defined in the OS.
Unless you want to try to hack the
keyboard's view hierarchy to change
that button, which would be a really
bad plan. (Standard recommendation
here is to file a bug report with
Apple to let them know you'd like
more/different options.)
see Custom iPhone return key text
Since I didn't get any satisfactory answer, I convinced the client that it would be inappropriate to modify the default system keyboard for a sake of one button(even if it is allowed by Apple). We are now going for the "Go" option available for return key.

Resources