Skip to content

Commit

Permalink
Merge pull request #33 from sakebook/issue/11_ios
Browse files Browse the repository at this point in the history
Support optional fileds in iOS
  • Loading branch information
sakebook authored Nov 10, 2019
2 parents 3c0f768 + f69e189 commit d2e09d7
Showing 4 changed files with 87 additions and 48 deletions.
40 changes: 20 additions & 20 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
PODS:
- Flutter (1.0.0)
- Google-Mobile-Ads-SDK (7.50.0):
- Google-Mobile-Ads-SDK (7.52.0):
- GoogleAppMeasurement (~> 6.0)
- GoogleAppMeasurement (6.1.2):
- GoogleAppMeasurement (6.1.5):
- GoogleUtilities/AppDelegateSwizzler (~> 6.0)
- GoogleUtilities/MethodSwizzler (~> 6.0)
- GoogleUtilities/Network (~> 6.0)
- "GoogleUtilities/NSData+zlib (~> 6.0)"
- nanopb (~> 0.3)
- GoogleUtilities/AppDelegateSwizzler (6.3.0):
- nanopb (= 0.3.9011)
- GoogleUtilities/AppDelegateSwizzler (6.3.1):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (6.3.0)
- GoogleUtilities/Logger (6.3.0):
- GoogleUtilities/Environment (6.3.1)
- GoogleUtilities/Logger (6.3.1):
- GoogleUtilities/Environment
- GoogleUtilities/MethodSwizzler (6.3.0):
- GoogleUtilities/MethodSwizzler (6.3.1):
- GoogleUtilities/Logger
- GoogleUtilities/Network (6.3.0):
- GoogleUtilities/Network (6.3.1):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (6.3.0)"
- GoogleUtilities/Reachability (6.3.0):
- "GoogleUtilities/NSData+zlib (6.3.1)"
- GoogleUtilities/Reachability (6.3.1):
- GoogleUtilities/Logger
- nanopb (0.3.901):
- nanopb/decode (= 0.3.901)
- nanopb/encode (= 0.3.901)
- nanopb/decode (0.3.901)
- nanopb/encode (0.3.901)
- nanopb (0.3.9011):
- nanopb/decode (= 0.3.9011)
- nanopb/encode (= 0.3.9011)
- nanopb/decode (0.3.9011)
- nanopb/encode (0.3.9011)
- native_ads (0.2.1):
- Flutter
- Google-Mobile-Ads-SDK
@@ -52,12 +52,12 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
Google-Mobile-Ads-SDK: d48dbaf5bae1ab7a94a9786f493c26c454bc6f16
GoogleAppMeasurement: 0ae90be1cc4dad40f4a27fc767ef59fa032ec87b
GoogleUtilities: 9c2c544202301110b29f7974a82e77fdcf12bf51
nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48
Google-Mobile-Ads-SDK: 62f6244637306cb60a1b4adda067f53224c7a860
GoogleAppMeasurement: 037f46d1d8ae8b312720f1042585ab961a1289e3
GoogleUtilities: f895fde57977df4e0233edda0dbeac490e3703b6
nanopb: 18003b5e52dab79db540fe93fe9579f399bd1ccd
native_ads: 8962a1e3c92cfdde302aa3515b6dd995643fbc8b

PODFILE CHECKSUM: b6a0a141693093b304368d08511b46cf3d1d0ac5

COCOAPODS: 1.8.1
COCOAPODS: 1.8.4
73 changes: 46 additions & 27 deletions example/ios/Runner/UnifiedNativeAdView.xib
Original file line number Diff line number Diff line change
@@ -1,75 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<device id="retina5_5" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<device id="retina5_5" orientation="portrait" appearance="dark"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<deployment version="4352" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15509"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="yna-He-Zdc" customClass="GADUnifiedNativeAdView">
<rect key="frame" x="0.0" y="0.0" width="440" height="320"/>
<rect key="frame" x="0.0" y="0.0" width="535" height="515"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="sample text sample text sample text" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Sfh-pp-4fG">
<rect key="frame" x="8" y="8" width="424" height="20"/>
<rect key="frame" x="112" y="8" width="415" height="96"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<nil key="textColor"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="er9-B4-IuD" customClass="GADMediaView">
<rect key="frame" x="8" y="64.333333333333329" width="424" height="218.66666666666669"/>
<rect key="frame" x="8" y="140.33333333333334" width="519" height="322.66666666666663"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="249" text="sample text sample text sample text sample text" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wiv-Yz-UOl">
<rect key="frame" x="8" y="36" width="424" height="20.333333333333329"/>
<rect key="frame" x="8" y="112" width="519" height="20.333333333333343"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" restorationIdentifier="flutter_native_ad_attribution_view_id" text="AD" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DWW-IQ-I8M">
<rect key="frame" x="8" y="291" width="24" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="call to action" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vXU-zn-QEk">
<rect key="frame" x="8" y="471" width="519" height="36"/>
<color key="backgroundColor" systemColor="systemRedColor" red="1" green="0.23137254900000001" blue="0.18823529410000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="36" id="fRm-g5-hxl"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="4"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="call to action" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vXU-zn-QEk">
<rect key="frame" x="334.66666666666669" y="291" width="97.333333333333314" height="21"/>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="kdF-cM-OSZ">
<rect key="frame" x="8" y="8" width="96" height="96"/>
<constraints>
<constraint firstAttribute="height" constant="96" id="0nv-EL-ZXA"/>
<constraint firstAttribute="width" constant="96" id="Rdt-ys-xau"/>
<constraint firstAttribute="width" secondItem="kdF-cM-OSZ" secondAttribute="height" multiplier="1:1" id="uD9-7b-TIt"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" restorationIdentifier="flutter_native_ad_attribution_view_id" text="AD" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DWW-IQ-I8M">
<rect key="frame" x="503" y="83" width="24" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Wiv-Yz-UOl" firstAttribute="leading" secondItem="yna-He-Zdc" secondAttribute="leading" constant="8" id="6JJ-C5-hPa"/>
<constraint firstItem="DWW-IQ-I8M" firstAttribute="top" secondItem="er9-B4-IuD" secondAttribute="bottom" constant="8" id="E7J-L4-TXx"/>
<constraint firstItem="DWW-IQ-I8M" firstAttribute="bottom" secondItem="kdF-cM-OSZ" secondAttribute="bottom" id="7Bn-tR-93r"/>
<constraint firstAttribute="trailing" secondItem="er9-B4-IuD" secondAttribute="trailing" constant="8" id="KEf-JL-21G"/>
<constraint firstItem="er9-B4-IuD" firstAttribute="leading" secondItem="yna-He-Zdc" secondAttribute="leading" constant="8" id="RdA-RL-viE"/>
<constraint firstAttribute="bottom" secondItem="vXU-zn-QEk" secondAttribute="bottom" constant="8" id="RyR-jG-sWb"/>
<constraint firstItem="kdF-cM-OSZ" firstAttribute="leading" secondItem="yna-He-Zdc" secondAttribute="leading" constant="8" id="UUt-BX-3l5"/>
<constraint firstAttribute="trailing" secondItem="vXU-zn-QEk" secondAttribute="trailing" constant="8" id="V3X-PN-zoW"/>
<constraint firstAttribute="trailing" secondItem="Sfh-pp-4fG" secondAttribute="trailing" constant="8" id="Wya-6p-I3L"/>
<constraint firstAttribute="trailing" secondItem="Wiv-Yz-UOl" secondAttribute="trailing" constant="8" id="Y5z-cE-HA1"/>
<constraint firstItem="kdF-cM-OSZ" firstAttribute="top" secondItem="yna-He-Zdc" secondAttribute="top" constant="8" id="YmO-R2-JHT"/>
<constraint firstItem="Sfh-pp-4fG" firstAttribute="top" secondItem="yna-He-Zdc" secondAttribute="top" constant="8" id="cuW-hc-kqC"/>
<constraint firstItem="Wiv-Yz-UOl" firstAttribute="top" secondItem="Sfh-pp-4fG" secondAttribute="bottom" constant="8" id="dVp-AX-Vqd"/>
<constraint firstAttribute="bottom" secondItem="DWW-IQ-I8M" secondAttribute="bottom" constant="8" id="e88-UF-fdL"/>
<constraint firstItem="DWW-IQ-I8M" firstAttribute="leading" secondItem="yna-He-Zdc" secondAttribute="leading" constant="8" id="h8K-eM-qb8"/>
<constraint firstAttribute="trailing" secondItem="DWW-IQ-I8M" secondAttribute="trailing" constant="8" id="eWg-an-FKe"/>
<constraint firstItem="Sfh-pp-4fG" firstAttribute="bottom" secondItem="kdF-cM-OSZ" secondAttribute="bottom" id="fLh-Yv-OdH"/>
<constraint firstItem="er9-B4-IuD" firstAttribute="top" secondItem="Wiv-Yz-UOl" secondAttribute="bottom" constant="8" id="mLi-8l-OIn"/>
<constraint firstItem="vXU-zn-QEk" firstAttribute="top" secondItem="er9-B4-IuD" secondAttribute="bottom" constant="8" id="nsM-7b-jU1"/>
<constraint firstItem="Sfh-pp-4fG" firstAttribute="leading" secondItem="yna-He-Zdc" secondAttribute="leading" constant="8" id="oMw-hh-R7Y"/>
<constraint firstItem="vXU-zn-QEk" firstAttribute="leading" secondItem="yna-He-Zdc" secondAttribute="leading" constant="8" id="t82-d5-a0N"/>
<constraint firstItem="Wiv-Yz-UOl" firstAttribute="top" secondItem="kdF-cM-OSZ" secondAttribute="bottom" constant="8" id="u9V-cH-xuQ"/>
<constraint firstItem="Sfh-pp-4fG" firstAttribute="leading" secondItem="kdF-cM-OSZ" secondAttribute="trailing" constant="8" id="yzO-t5-5J6"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="bodyView" destination="Wiv-Yz-UOl" id="hpV-JF-Mbp"/>
<outlet property="bodyView" destination="Wiv-Yz-UOl" id="QvV-Lm-yeW"/>
<outlet property="callToActionView" destination="vXU-zn-QEk" id="SJM-Sz-mkk"/>
<outlet property="headlineView" destination="Sfh-pp-4fG" id="v1H-7s-8HQ"/>
<outlet property="headlineView" destination="Sfh-pp-4fG" id="w5V-Gj-cRk"/>
<outlet property="iconView" destination="kdF-cM-OSZ" id="Nvt-N1-BLQ"/>
<outlet property="mediaView" destination="er9-B4-IuD" id="l5R-ch-td1"/>
</connections>
<point key="canvasLocation" x="420.28985507246381" y="-282.06521739130437"/>
<point key="canvasLocation" x="489.13043478260875" y="-259.64673913043481"/>
</view>
</objects>
</document>
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: native_ads_example
description: Demonstrates how to use the native_ads plugin.
publish_to: 'none'
version: 0.2.1

environment:
sdk: ">=2.1.0 <3.0.0"
21 changes: 20 additions & 1 deletion ios/Classes/UnifiedAdLayout.swift
Original file line number Diff line number Diff line change
@@ -27,6 +27,12 @@ class UnifiedAdLayout : NSObject, FlutterPlatformView {
private weak var callToActionView: UILabel!
private weak var mediaView: GADMediaView!
private weak var attributionView: UILabel!

private weak var iconView: UIImageView?
private weak var starRatingView: UILabel?
private weak var storeView: UILabel?
private weak var priceView: UILabel?
private weak var advertiserView: UILabel?

init(frame: CGRect, viewId: Int64, args: [String: Any], messeneger: FlutterBinaryMessenger) {
self.args = args
@@ -64,7 +70,13 @@ class UnifiedAdLayout : NSObject, FlutterPlatformView {
fatalError("Could not find Restoration ID 'flutter_native_ad_attribution_view_id'")
}
attributionView = attributionLabel


iconView = adView.iconView as? UIImageView
starRatingView = adView.starRatingView as? UILabel
storeView = adView.storeView as? UILabel
priceView = adView.priceView as? UILabel
advertiserView = adView.advertiserView as? UILabel

fetchAd()
return unifiedNativeAdView
}
@@ -88,6 +100,13 @@ extension UnifiedAdLayout : GADUnifiedNativeAdLoaderDelegate {
mediaView?.mediaContent = nativeAd.mediaContent
attributionView.text = attributionText
unifiedNativeAdView.nativeAd = nativeAd

iconView?.image = nativeAd.icon?.image
starRatingView?.text = String(describing: nativeAd.starRating?.doubleValue)
storeView?.text = nativeAd.store
priceView?.text = nativeAd.price
advertiserView?.text = nativeAd.advertiser

// Set ourselves as the native ad delegate to be notified of native ad events.
nativeAd.delegate = self
}

0 comments on commit d2e09d7

Please sign in to comment.