From 14e0d0dffb9ee8b1d41d60ccbcfd63d53bfe4d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascoal=20J=C3=BAnior?= Date: Mon, 16 Sep 2024 07:27:01 -0700 Subject: [PATCH] Add support for new iOS text content type cellular EID and cellular IMEI (#46378) Summary: Support for new iOS text content type to autofill cellular EID or cellular IMEI: - https://developer.apple.com/documentation/uikit/uitextcontenttypecellulareid?language=objc - https://developer.apple.com/documentation/uikit/uitextcontenttypecellularimei?language=objc ## Changelog: [IOS] [ADDED] - new text content type cellular EID and cellular IMEI Pull Request resolved: https://github.com/facebook/react-native/pull/46378 Test Plan: JavaScript Tests - yarn test [PASSED] - No errors related with the changes Flow - yarn flow && yarn lint [PASSED] - No errors related with the changes iOS Tests - ./scripts/objc-test.sh test [PASSED] - No errors related with the changes Build RNTester [PASSED] - No errors related with the changes - Proof: Screenshot 2024-09-07 at 12 06 48 Screenshot 2024-09-07 at 12 07 29 Screenshot 2024-09-07 at 12 13 02 ![Simulator Screenshot - iPhone 15 Pro - 2024-09-07 at 12 06 36](https://github.com/user-attachments/assets/9411c9d9-0b93-4f47-b21c-cbd95810f4c7) Note: Since the test was done using an iOS simulator the autofill suggestion won't appear for the cellularEID or cellularIMEI Reviewed By: cortinico Differential Revision: D62386126 Pulled By: cipolleschi fbshipit-source-id: 50da572650b796d0426a15f0c06fd0c52a8247f5 --- .../Libraries/Text/TextInput/RCTBaseTextInputView.mm | 9 +++++++++ .../ComponentViews/TextInput/RCTTextInputUtils.mm | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm b/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm index b0c645fa812..349e53cef6f 100644 --- a/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm +++ b/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm @@ -323,6 +323,15 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame) @"birthdateYear" : UITextContentTypeBirthdateYear, }]; } + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 170400 /* __IPHONE_17_4 */ + if (@available(iOS 17.4, *)) { + [mutableContentTypeMap addEntriesFromDictionary:@{ + @"cellularEID" : UITextContentTypeCellularEID, + @"cellularIMEI" : UITextContentTypeCellularIMEI, + }]; + } +#endif #endif contentTypeMap = mutableContentTypeMap; diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm index 63457587162..2b0278d31b7 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm @@ -240,6 +240,15 @@ UITextContentType RCTUITextContentTypeFromString(const std::string &contentType) @"birthdateYear" : UITextContentTypeBirthdateYear, }]; } + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 170400 /* __IPHONE_17_4 */ + if (@available(iOS 17.4, *)) { + [mutableContentTypeMap addEntriesFromDictionary:@{ + @"cellularEID" : UITextContentTypeCellularEID, + @"cellularIMEI" : UITextContentTypeCellularIMEI, + }]; + } +#endif #endif contentTypeMap = mutableContentTypeMap;