I've implemented a notification content extension in order to get action buttons to show up properly in my app. All I need for my notifications is the default header and the action buttons, no interface. As such, I want to hide the interface or shrink its size to zero but nothing has worked.
I've tried updating the size in ViewDidLoad()
in the ViewController
like so:
public override void ViewDidLoad()
{
base.ViewDidLoad();
PreferredContentSize = new CoreGraphics.CGSize(0, 0);
ContentSizeForViewInPopover = PreferredContentSize;
View.SetNeedsUpdateConstraints();
View.SetNeedsLayout();
UpdateViewConstraints();
// Do any required interface initialization here.
}
I've tried changing the ViewController
to FreeForm
in XCode and setting its Width and Height to 0
I've also set the width and height to the view in the storeboard file to 0.
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="M4Y-Lb-cyx">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Notification View Controller-->
<scene sceneID="cwh-vc-ff4">
<objects>
<viewController id="M4Y-Lb-cyx" userLabel="Notification View Controller" customClass="NotificationViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="sVI-DA-27z"/>
<viewControllerLayoutGuide type="bottom" id="WK5-y5-Ae8"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" simulatedAppContext="notificationCenter" id="S3S-Oj-5AN">
<rect key="frame" x="0.0" y="0.0" width="0" height="0"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.45882353186607361" green="0.74901962280273438" blue="0.66666668653488159" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<value key="contentSizeForViewInPopover" type="size" width="0.0" height="0.0"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="vXp-U4-Rya" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-33" y="-8"/>
</scene>
</scenes>
</document>
Nothing has worked. How can I shrink / hide / remove the interface in the push notification so that it only has the header and the buttons?
According to the Setting the Notification Content Extension's categories, you may try the following things to remove the content:
1.Setting the content area size
Edit the Info.plist file for the Extension and set the UNNotificationExtensionInitialContentSizeRatio key of the NSExtensionAttributes key to type Number with a very small value, such as zero.
2.Hiding the default notification content
Add the UNNotificationExtensionDefaultContentHidden key to the NSExtensionAttributes key as type Boolean with a value of YES in the Extension's Info.plist file.
For more info, you could refer to Apple's doc for UNNotificationExtensionInitialContentSizeRatio .
Hope it helps!