Skip to content

Commit 95f2c0e

Browse files
authored
Merge pull request #1338 from OneSignal/add_get_tags
Add public `getTags` method
2 parents e1e02a2 + 494ad47 commit 95f2c0e

File tree

9 files changed

+41
-30
lines changed

9 files changed

+41
-30
lines changed

MIGRATION_GUIDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ The User name space is accessible via `OneSignal.User` and provides access to us
331331
| `OneSignal.User.addTag(key: "KEY", value: "VALUE")` | `[OneSignal.User addTagWithKey:@"KEY" value:@"VALUE"]` | *Add a tag for the current user. Tags are key:value pairs used as building blocks for targeting specific users and/or personalizing messages. If the tag key already exists, it will be replaced with the value provided here.* |
332332
| `OneSignal.User.addTags(["KEY_01": "VALUE_01", "KEY_02": "VALUE_02"])` | `[OneSignal.User addTags:@{@"KEY_01": @"VALUE_01", @"KEY_02": @"VALUE_02"}]` | *Add multiple tags for the current user. Tags are key:value pairs used as building blocks for targeting specific users and/or personalizing messages. If the tag key already exists, it will be replaced with the value provided here.* |
333333
| `OneSignal.User.removeTag("KEY")` | `[OneSignal.User removeTag:@"KEY"]` | *Remove the data tag with the provided key from the current user.* |
334+
| `let tags = OneSignal.User.getTags()` | `NSDictionary<NSString *, NSString*> *tags = [OneSignal.User getTags]` | *Returns the local tags for the current user.* |
334335
| `OneSignal.User.removeTags(["KEY_01", "KEY_02"])` | `[OneSignal.User removeTags:@[@"KEY_01", @"KEY_02"]]` | *Remove multiple tags with the provided keys from the current user.* |
335336

336337

iOS_SDK/OneSignalDevApp/OneSignalDevApp/Base.lproj/Main.storyboard

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
33
<device id="retina5_5" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
77
<capability name="System colors in document resources" minToolsVersion="11.0"/>
88
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
99
</dependencies>
@@ -20,7 +20,7 @@
2020
<rect key="frame" x="0.0" y="0.0" width="375" height="2500"/>
2121
<subviews>
2222
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" horizontalHuggingPriority="1" verticalHuggingPriority="1" horizontalCompressionResistancePriority="1" verticalCompressionResistancePriority="1" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" delaysContentTouches="NO" keyboardDismissMode="onDrag" translatesAutoresizingMaskIntoConstraints="NO" id="Dse-f7-S3F">
23-
<rect key="frame" x="0.0" y="0.0" width="375" height="2500"/>
23+
<rect key="frame" x="0.0" y="20" width="375" height="2480"/>
2424
<subviews>
2525
<view contentMode="scaleAspectFit" horizontalHuggingPriority="1" verticalHuggingPriority="1" horizontalCompressionResistancePriority="1" verticalCompressionResistancePriority="1" translatesAutoresizingMaskIntoConstraints="NO" id="6dV-2z-2jJ">
2626
<rect key="frame" x="0.0" y="0.0" width="375" height="2500"/>
@@ -43,9 +43,9 @@
4343
<constraint firstAttribute="width" constant="68" id="com-ja-CVD"/>
4444
</constraints>
4545
<color key="tintColor" red="1" green="0.1367101157" blue="0.01701983743" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
46-
<state key="normal" title="Get Info"/>
46+
<state key="normal" title="Get Tags"/>
4747
<connections>
48-
<action selector="getInfoButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Pp8-oA-Zrh"/>
48+
<action selector="getTagsButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Pp8-oA-Zrh"/>
4949
</connections>
5050
</button>
5151
<button opaque="NO" contentMode="scaleToFill" selected="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="UPh-ZU-o2e">
@@ -680,10 +680,10 @@
680680
</constraints>
681681
<variation key="default">
682682
<mask key="constraints">
683-
<exclude reference="DGT-HM-vmK"/>
684-
<exclude reference="hN8-d5-5HN"/>
685-
<exclude reference="7Fw-oC-CwE"/>
686683
<exclude reference="dGl-mF-7SU"/>
684+
<exclude reference="7Fw-oC-CwE"/>
685+
<exclude reference="hN8-d5-5HN"/>
686+
<exclude reference="DGT-HM-vmK"/>
687687
<exclude reference="Shu-w2-y8O"/>
688688
<exclude reference="ojL-ev-kNn"/>
689689
</mask>
@@ -723,7 +723,7 @@
723723
<outlet property="consentSegmentedControl" destination="05S-ud-V2e" id="9HS-Rj-OmM"/>
724724
<outlet property="emailTextField" destination="9me-S6-lrh" id="uDb-iR-fog"/>
725725
<outlet property="externalUserIdTextField" destination="H7c-2l-Pkl" id="t1X-F3-GWv"/>
726-
<outlet property="getInfoButton" destination="Htv-x2-aPb" id="EK5-1t-g6g"/>
726+
<outlet property="getTagsButton" destination="Htv-x2-aPb" id="EK5-1t-g6g"/>
727727
<outlet property="getTriggerKey" destination="bmb-ib-r40" id="Sge-3X-okn"/>
728728
<outlet property="inAppMessagingSegmentedControl" destination="saG-x9-o6U" id="gox-lD-D3j"/>
729729
<outlet property="languageTextField" destination="bYz-SP-tnS" id="OoH-FW-N0w"/>

iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
@property (weak, nonatomic) IBOutlet UITextField *appIdTextField;
3939
@property (weak, nonatomic) IBOutlet UIButton *updateAppIdButton;
4040
@property (weak, nonatomic) IBOutlet UIButton *sendTagButton;
41-
@property (weak, nonatomic) IBOutlet UIButton *getInfoButton;
41+
@property (weak, nonatomic) IBOutlet UIButton *getTagsButton;
4242
@property (weak, nonatomic) IBOutlet UIButton *sendTagsButton;
4343
@property (weak, nonatomic) IBOutlet UIButton *promptPushButton;
4444
@property (weak, nonatomic) IBOutlet UIButton *promptLocationButton;

iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ - (IBAction)sendTagButton:(id)sender {
128128
}
129129
}
130130

131-
- (IBAction)getInfoButton:(id)sender {
132-
NSLog(@"Dev App: get User and Device information, you need to fill in");
131+
- (IBAction)getTagsButton:(id)sender {
132+
NSDictionary<NSString *, NSString*> *tags = [OneSignal.User getTags];
133+
NSLog(@"Tags: %@", tags);
133134
}
134135

135136
- (IBAction)sendTagsButton:(id)sender {

iOS_SDK/OneSignalDevApp/OneSignalDevAppClip/Base.lproj/Main.storyboard

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
33
<device id="retina6_12" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
77
<capability name="System colors in document resources" minToolsVersion="11.0"/>
88
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
99
</dependencies>
@@ -20,7 +20,7 @@
2020
<rect key="frame" x="0.0" y="0.0" width="375" height="820"/>
2121
<subviews>
2222
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" horizontalHuggingPriority="1" verticalHuggingPriority="1" horizontalCompressionResistancePriority="1" verticalCompressionResistancePriority="1" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" delaysContentTouches="NO" keyboardDismissMode="onDrag" translatesAutoresizingMaskIntoConstraints="NO" id="Dse-f7-S3F">
23-
<rect key="frame" x="0.0" y="59" width="375" height="759"/>
23+
<rect key="frame" x="0.0" y="59" width="375" height="727"/>
2424
<subviews>
2525
<view contentMode="scaleAspectFit" horizontalHuggingPriority="1" verticalHuggingPriority="1" horizontalCompressionResistancePriority="1" verticalCompressionResistancePriority="1" translatesAutoresizingMaskIntoConstraints="NO" id="6dV-2z-2jJ">
2626
<rect key="frame" x="0.0" y="0.0" width="375" height="1174"/>
@@ -40,9 +40,9 @@
4040
<constraint firstAttribute="width" constant="68" id="com-ja-CVD"/>
4141
</constraints>
4242
<color key="tintColor" red="1" green="0.1367101157" blue="0.01701983743" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
43-
<state key="normal" title="Get Info"/>
43+
<state key="normal" title="Get Tags"/>
4444
<connections>
45-
<action selector="getInfoButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Pp8-oA-Zrh"/>
45+
<action selector="getTagsButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Pp8-oA-Zrh"/>
4646
</connections>
4747
</button>
4848
<button opaque="NO" contentMode="scaleToFill" selected="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="UPh-ZU-o2e">
@@ -282,7 +282,7 @@
282282
</connections>
283283
</segmentedControl>
284284
<button opaque="NO" contentMode="scaleToFill" selected="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="srQ-s9-3O9" userLabel="Update App Id">
285-
<rect key="frame" x="120.66666666666669" y="519" width="136" height="30"/>
285+
<rect key="frame" x="104.66666666666669" y="519" width="168" height="30"/>
286286
<fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="15"/>
287287
<color key="tintColor" red="1" green="0.1367101157" blue="0.01701983743" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
288288
<state key="normal" title="Login to External User Id"/>
@@ -305,7 +305,7 @@
305305
<textInputTraits key="textInputTraits"/>
306306
</textField>
307307
<button opaque="NO" contentMode="scaleToFill" selected="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fmV-3f-ILa" userLabel="Update App Id">
308-
<rect key="frame" x="157.66666666666666" y="394" width="64" height="30"/>
308+
<rect key="frame" x="155.66666666666666" y="394" width="68" height="30"/>
309309
<fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="15"/>
310310
<color key="tintColor" red="1" green="0.1367101157" blue="0.01701983743" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
311311
<state key="normal" title="Add Email"/>
@@ -327,7 +327,7 @@
327327
</connections>
328328
</button>
329329
<button opaque="NO" contentMode="scaleToFill" selected="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7ll-OX-6Qj" userLabel="Update App Id">
330-
<rect key="frame" x="143" y="432" width="89" height="30"/>
330+
<rect key="frame" x="139.66666666666666" y="432" width="96" height="30"/>
331331
<fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="15"/>
332332
<color key="tintColor" red="1" green="0.1367101157" blue="0.01701983743" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
333333
<state key="normal" title="Remove Email"/>
@@ -470,6 +470,7 @@
470470
<extendedEdge key="edgesForExtendedLayout" top="YES"/>
471471
<size key="freeformSize" width="375" height="820"/>
472472
<connections>
473+
<outlet property="addEmailButton" destination="fmV-3f-ILa" id="7BW-qA-1Zl"/>
473474
<outlet property="addTriggerButton" destination="79P-xw-1Q5" id="eNO-ar-yk2"/>
474475
<outlet property="addTriggerKey" destination="Ykz-Wq-cb5" id="JiT-E7-Dof"/>
475476
<outlet property="addTriggerValue" destination="G56-cW-rWo" id="sVO-uj-cMD"/>
@@ -478,24 +479,23 @@
478479
<outlet property="consentSegmentedControl" destination="05S-ud-V2e" id="9HS-Rj-OmM"/>
479480
<outlet property="emailTextField" destination="9me-S6-lrh" id="uDb-iR-fog"/>
480481
<outlet property="externalUserIdTextField" destination="H7c-2l-Pkl" id="t1X-F3-GWv"/>
481-
<outlet property="getInfoButton" destination="Htv-x2-aPb" id="EK5-1t-g6g"/>
482+
<outlet property="getTagsButton" destination="Htv-x2-aPb" id="EK5-1t-g6g"/>
482483
<outlet property="getTriggerKey" destination="bmb-ib-r40" id="Sge-3X-okn"/>
483484
<outlet property="inAppMessagingSegmentedControl" destination="saG-x9-o6U" id="gox-lD-D3j"/>
484485
<outlet property="infoLabel" destination="7au-a5-gty" id="CMF-lK-qHp"/>
485486
<outlet property="locationSharedSegementedControl" destination="udx-VH-OPB" id="ByV-wf-96W"/>
486-
<outlet property="removeEmailButton" destination="7ll-OX-6Qj" id="cTQ-3S-iCj"/>
487+
<outlet property="loginExternalUserIdButton" destination="srQ-s9-3O9" id="yVV-xK-CdB"/>
488+
<outlet property="logoutButton" destination="OiG-L7-Ot2" id="60f-Lo-ePF"/>
487489
<outlet property="outcomeName" destination="Whw-1A-6W0" id="19x-BU-e6z"/>
488490
<outlet property="outcomeUniqueName" destination="9Tw-qJ-FVq" id="f2a-wB-awc"/>
489491
<outlet property="outcomeValue" destination="knZ-rP-bRU" id="EnV-7t-ETR"/>
490492
<outlet property="outcomeValueName" destination="Xj9-lX-hR2" id="Dhu-Pd-sBU"/>
491493
<outlet property="promptLocationButton" destination="UPh-ZU-o2e" id="pAW-KU-PZX"/>
492494
<outlet property="promptPushButton" destination="YNF-Jm-wDq" id="J0U-WU-1w0"/>
493-
<outlet property="logoutButton" destination="OiG-L7-Ot2" id="60f-Lo-ePF"/>
495+
<outlet property="removeEmailButton" destination="7ll-OX-6Qj" id="cTQ-3S-iCj"/>
494496
<outlet property="removeTriggerKey" destination="cWh-Hu-7CP" id="j0S-4T-AXs"/>
495497
<outlet property="result" destination="XKn-G6-r2q" id="bPC-p9-k4N"/>
496498
<outlet property="sendTagsButton" destination="H3K-GA-smE" id="rCS-pd-avT"/>
497-
<outlet property="addEmailButton" destination="fmV-3f-ILa" id="7BW-qA-1Zl"/>
498-
<outlet property="loginExternalUserIdButton" destination="srQ-s9-3O9" id="yVV-xK-CdB"/>
499499
<outlet property="subscriptionSegmentedControl" destination="gZI-5K-94s" id="CCF-Qh-9Xg"/>
500500
<outlet property="updateAppIdButton" destination="Kp7-Oh-BQ1" id="jFd-CJ-ExJ"/>
501501
</connections>

iOS_SDK/OneSignalDevApp/OneSignalDevAppClip/ViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
@property (weak, nonatomic) IBOutlet UISegmentedControl *consentSegmentedControl;
3838
@property (weak, nonatomic) IBOutlet UITextField *appIdTextField;
3939
@property (weak, nonatomic) IBOutlet UIButton *updateAppIdButton;
40-
@property (weak, nonatomic) IBOutlet UIButton *getInfoButton;
40+
@property (weak, nonatomic) IBOutlet UIButton *getTagsButton;
4141
@property (weak, nonatomic) IBOutlet UIButton *sendTagsButton;
4242
@property (weak, nonatomic) IBOutlet UIButton *promptPushButton;
4343
@property (weak, nonatomic) IBOutlet UIButton *promptLocationButton;

iOS_SDK/OneSignalDevApp/OneSignalDevAppClip/ViewController.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ - (IBAction)removeEmailButton:(id)sender {
8888
[OneSignal.User removeEmail:email];
8989
}
9090

91-
- (IBAction)getInfoButton:(id)sender {
92-
NSLog(@"getTags no longer supported");
91+
- (IBAction)getTagsButton:(id)sender {
92+
NSDictionary<NSString *, NSString*> *tags = [OneSignal.User getTags];
93+
NSLog(@"Tags: %@", tags);
9394
}
9495

9596
- (IBAction)sendTagsButton:(id)sender {

0 commit comments

Comments
 (0)