Skip to content

Commit 82add8b

Browse files
remove instanceID from quickstart app
1 parent a2697ab commit 82add8b

File tree

5 files changed

+21
-24
lines changed

5 files changed

+21
-24
lines changed

messaging/MessagingExample/Base.lproj/Main.storyboard

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="dvH-Ce-6yG">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18121" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="dvH-Ce-6yG">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18091"/>
97
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
108
</dependencies>
119
<scenes>
@@ -21,7 +19,7 @@
2119
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2220
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2321
<subviews>
24-
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="S9T-hp-Ka1">
22+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="S9T-hp-Ka1">
2523
<rect key="frame" x="107.5" y="311.5" width="160" height="44"/>
2624
<constraints>
2725
<constraint firstAttribute="height" constant="44" id="Grv-Ur-3qm"/>
@@ -33,7 +31,7 @@
3331
<action selector="handleLogTokenTouch:" destination="BYZ-38-t0r" eventType="touchUpInside" id="3NM-R6-4A4"/>
3432
</connections>
3533
</button>
36-
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HgF-jF-1NC">
34+
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HgF-jF-1NC">
3735
<rect key="frame" x="204" y="233" width="192" height="44"/>
3836
<color key="backgroundColor" red="1" green="0.56078431370000004" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3937
<constraints>
@@ -57,7 +55,7 @@
5755
<nil key="textColor"/>
5856
<nil key="highlightedColor"/>
5957
</label>
60-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No InstanceID token" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="5" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1wF-0v-e01">
58+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No FCM Registration token" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="5" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1wF-0v-e01">
6159
<rect key="frame" x="67.5" y="565" width="240" height="13.5"/>
6260
<constraints>
6361
<constraint firstAttribute="width" constant="240" id="FXq-Tm-sRh"/>
@@ -83,7 +81,7 @@
8381
<navigationItem key="navigationItem" title="FCM Example" id="uI5-jL-nrY"/>
8482
<connections>
8583
<outlet property="fcmTokenMessage" destination="RBg-uJ-gCV" id="FUs-GZ-mfF"/>
86-
<outlet property="instanceIDTokenMessage" destination="1wF-0v-e01" id="Dmb-Lh-hLD"/>
84+
<outlet property="remoteFCMTokenMessage" destination="1wF-0v-e01" id="nDz-D9-60k"/>
8785
</connections>
8886
</viewController>
8987
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
@@ -95,7 +93,7 @@
9593
<objects>
9694
<navigationController id="dvH-Ce-6yG" sceneMemberID="viewController">
9795
<navigationBar key="navigationBar" contentMode="scaleToFill" barStyle="black" id="FZU-Jb-Wzn">
98-
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
96+
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
9997
<autoresizingMask key="autoresizingMask"/>
10098
<color key="barTintColor" red="0.0" green="0.52156862745098043" blue="0.88627450980392153" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
10199
</navigationBar>

messaging/MessagingExample/ViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818

1919
@interface ViewController : UIViewController
2020
@property (weak, nonatomic) IBOutlet UILabel *fcmTokenMessage;
21-
@property (weak, nonatomic) IBOutlet UILabel *instanceIDTokenMessage;
21+
@property (weak, nonatomic) IBOutlet UILabel *remoteFCMTokenMessage;
2222
@end

messaging/MessagingExample/ViewController.m

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@ - (IBAction)handleLogTokenTouch:(id)sender {
3636
self.fcmTokenMessage.text = displayToken;
3737

3838
// [START log_iid_reg_token]
39-
[[FIRInstanceID instanceID] instanceIDWithHandler:^(FIRInstanceIDResult * _Nullable result,
40-
NSError * _Nullable error) {
39+
[[FIRMessaging messaging] tokenWithCompletion:^(NSString * _Nullable token, NSError * _Nullable error) {
4140
if (error != nil) {
42-
NSLog(@"Error fetching remote instance ID: %@", error);
41+
NSLog(@"Error fetching the remote FCM registration token: %@", error);
4342
} else {
44-
NSLog(@"Remote instance ID token: %@", result.token);
43+
NSLog(@"Remote FCM registration token: %@", token);
4544
NSString* message =
46-
[NSString stringWithFormat:@"Remote InstanceID token: %@", result.token];
47-
self.instanceIDTokenMessage.text = message;
45+
[NSString stringWithFormat:@"FCM registration token: %@", token];
46+
self.remoteFCMTokenMessage.text = message;
4847
}
4948
}];
5049
// [END log_iid_reg_token]

messaging/MessagingExampleSwift/ViewController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Firebase
2121
class ViewController: UIViewController {
2222

2323
@IBOutlet weak var fcmTokenMessage: UILabel!
24-
@IBOutlet weak var instanceIDTokenMessage: UILabel!
24+
@IBOutlet weak var remoteFCMTokenMessage: UILabel!
2525

2626
override func viewDidLoad() {
2727
NotificationCenter.default.addObserver(self, selector: #selector(self.displayFCMToken(notification:)),
@@ -36,12 +36,12 @@ class ViewController: UIViewController {
3636
self.fcmTokenMessage.text = "Logged FCM token: \(token ?? "")"
3737

3838
// [START log_iid_reg_token]
39-
InstanceID.instanceID().instanceID { (result, error) in
39+
Messaging.messaging().token { (token, error) in
4040
if let error = error {
41-
print("Error fetching remote instance ID: \(error)")
41+
print("Error fetching remote FCM registration token: \(error)")
4242
} else if let result = result {
4343
print("Remote instance ID token: \(result.token)")
44-
self.instanceIDTokenMessage.text = "Remote InstanceID token: \(result.token)"
44+
self.remoteFCMTokenMessage.text = "Remote FCM registration token: \(result.token)"
4545
}
4646
}
4747
// [END log_iid_reg_token]

messaging/MessagingExampleUITests/MessagingExampleUITests.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ - (void)testVerifyAppLaunched {
7676

7777
// Wait till network call is finished.
7878
NSPredicate *gone = [NSPredicate predicateWithFormat:@"exists == false"];
79-
FIRWaitForPredicateWithTimeout(gone, [_app staticTexts][@"No InstanceID token"], 20);
79+
FIRWaitForPredicateWithTimeout(gone, [_app staticTexts][@"No FCM Registration token"], 20);
8080

8181
// Make sure [FIRMessaging messaging].FCMToken returns FCM token.
8282
XCTAssertTrue(
8383
[[[[_app staticTexts] elementBoundByIndex:1] label] containsString:@"Logged FCM token"]);
84-
// Make sure [FIRInstanceID instanceID] instanceIDWithHandler: returns FCM token.
84+
// Make sure [FIRMessaging messaging] tokenWithCompletion: returns FCM token.
8585
XCTAssertTrue([[[[_app staticTexts] elementBoundByIndex:2] label]
86-
containsString:@"Remote InstanceID token"]);
86+
containsString:@"FCM registration token"]);
8787
}
8888

8989
@end

0 commit comments

Comments
 (0)