From 82100b4c96d0d73613a47ad8e6378a5980a8e09a Mon Sep 17 00:00:00 2001 From: Ramya Date: Tue, 24 Sep 2019 13:48:33 -0700 Subject: [PATCH] Adding MSAL objC sample --- .../MSALiOSobjC.xcodeproj/project.pbxproj | 425 ++++++++++++++++++ iOS-ObjC/MSALiOSobjC/AppDelegate.h | 37 ++ iOS-ObjC/MSALiOSobjC/AppDelegate.m | 70 +++ .../AppIcon.appiconset/Contents.json | 98 ++++ .../MSALiOSobjC/Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 ++ .../MSALiOSobjC/Base.lproj/Main.storyboard | 58 +++ iOS-ObjC/MSALiOSobjC/Info.plist | 56 +++ iOS-ObjC/MSALiOSobjC/MSALiOSobjC.entitlements | 11 + iOS-ObjC/MSALiOSobjC/ViewController.h | 37 ++ iOS-ObjC/MSALiOSobjC/ViewController.m | 278 ++++++++++++ iOS-ObjC/MSALiOSobjC/main.m | 35 ++ iOS-ObjC/Podfile | 11 + 13 files changed, 1147 insertions(+) create mode 100644 iOS-ObjC/MSALiOSobjC.xcodeproj/project.pbxproj create mode 100644 iOS-ObjC/MSALiOSobjC/AppDelegate.h create mode 100644 iOS-ObjC/MSALiOSobjC/AppDelegate.m create mode 100644 iOS-ObjC/MSALiOSobjC/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 iOS-ObjC/MSALiOSobjC/Assets.xcassets/Contents.json create mode 100644 iOS-ObjC/MSALiOSobjC/Base.lproj/LaunchScreen.storyboard create mode 100644 iOS-ObjC/MSALiOSobjC/Base.lproj/Main.storyboard create mode 100644 iOS-ObjC/MSALiOSobjC/Info.plist create mode 100644 iOS-ObjC/MSALiOSobjC/MSALiOSobjC.entitlements create mode 100644 iOS-ObjC/MSALiOSobjC/ViewController.h create mode 100644 iOS-ObjC/MSALiOSobjC/ViewController.m create mode 100644 iOS-ObjC/MSALiOSobjC/main.m create mode 100644 iOS-ObjC/Podfile diff --git a/iOS-ObjC/MSALiOSobjC.xcodeproj/project.pbxproj b/iOS-ObjC/MSALiOSobjC.xcodeproj/project.pbxproj new file mode 100644 index 0000000..ff0b192 --- /dev/null +++ b/iOS-ObjC/MSALiOSobjC.xcodeproj/project.pbxproj @@ -0,0 +1,425 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXBuildFile section */ + AD5F8674B31B72ECF5D791EB /* Pods_MSALiOSobjC.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0D326DF73C4535704D10F5B /* Pods_MSALiOSobjC.framework */; }; + DF7C1B132319B56E00BE9EF2 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DF7C1B122319B56E00BE9EF2 /* AppDelegate.m */; }; + DF7C1B162319B56E00BE9EF2 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DF7C1B152319B56E00BE9EF2 /* ViewController.m */; }; + DF7C1B192319B56E00BE9EF2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DF7C1B172319B56E00BE9EF2 /* Main.storyboard */; }; + DF7C1B1B2319B57300BE9EF2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DF7C1B1A2319B57300BE9EF2 /* Assets.xcassets */; }; + DF7C1B1E2319B57300BE9EF2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DF7C1B1C2319B57300BE9EF2 /* LaunchScreen.storyboard */; }; + DF7C1B212319B57300BE9EF2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DF7C1B202319B57300BE9EF2 /* main.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 468A646A4BCC93681BB7849C /* Pods-MSALiOSobjC.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MSALiOSobjC.release.xcconfig"; path = "Target Support Files/Pods-MSALiOSobjC/Pods-MSALiOSobjC.release.xcconfig"; sourceTree = ""; }; + 62935DAB3133D63E8EC77C6E /* Pods-objCSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-objCSample.debug.xcconfig"; path = "Target Support Files/Pods-objCSample/Pods-objCSample.debug.xcconfig"; sourceTree = ""; }; + C0ED207111DA16C4540CF929 /* Pods-MSALiOSobjC.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MSALiOSobjC.debug.xcconfig"; path = "Target Support Files/Pods-MSALiOSobjC/Pods-MSALiOSobjC.debug.xcconfig"; sourceTree = ""; }; + D0D326DF73C4535704D10F5B /* Pods_MSALiOSobjC.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MSALiOSobjC.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + D90FEB474F4EDBE59FCE4F4A /* Pods-objCSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-objCSample.release.xcconfig"; path = "Target Support Files/Pods-objCSample/Pods-objCSample.release.xcconfig"; sourceTree = ""; }; + DF7C1B0E2319B56E00BE9EF2 /* MSALiOSobjC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MSALiOSobjC.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DF7C1B112319B56E00BE9EF2 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + DF7C1B122319B56E00BE9EF2 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + DF7C1B142319B56E00BE9EF2 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + DF7C1B152319B56E00BE9EF2 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + DF7C1B182319B56E00BE9EF2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + DF7C1B1A2319B57300BE9EF2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + DF7C1B1D2319B57300BE9EF2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + DF7C1B1F2319B57300BE9EF2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + DF7C1B202319B57300BE9EF2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + DF7C1B272325BE7000BE9EF2 /* MSALiOSobjC.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MSALiOSobjC.entitlements; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + DF7C1B0B2319B56E00BE9EF2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + AD5F8674B31B72ECF5D791EB /* Pods_MSALiOSobjC.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 00766A40F4B1820C6AD27DA5 /* Pods */ = { + isa = PBXGroup; + children = ( + 62935DAB3133D63E8EC77C6E /* Pods-objCSample.debug.xcconfig */, + D90FEB474F4EDBE59FCE4F4A /* Pods-objCSample.release.xcconfig */, + C0ED207111DA16C4540CF929 /* Pods-MSALiOSobjC.debug.xcconfig */, + 468A646A4BCC93681BB7849C /* Pods-MSALiOSobjC.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + DF7C1B052319B56D00BE9EF2 = { + isa = PBXGroup; + children = ( + DF7C1B102319B56E00BE9EF2 /* MSALiOSobjC */, + DF7C1B0F2319B56E00BE9EF2 /* Products */, + 00766A40F4B1820C6AD27DA5 /* Pods */, + E1C3514B9C5043504D1805C8 /* Frameworks */, + ); + sourceTree = ""; + }; + DF7C1B0F2319B56E00BE9EF2 /* Products */ = { + isa = PBXGroup; + children = ( + DF7C1B0E2319B56E00BE9EF2 /* MSALiOSobjC.app */, + ); + name = Products; + sourceTree = ""; + }; + DF7C1B102319B56E00BE9EF2 /* MSALiOSobjC */ = { + isa = PBXGroup; + children = ( + DF7C1B272325BE7000BE9EF2 /* MSALiOSobjC.entitlements */, + DF7C1B152319B56E00BE9EF2 /* ViewController.m */, + DF7C1B112319B56E00BE9EF2 /* AppDelegate.h */, + DF7C1B122319B56E00BE9EF2 /* AppDelegate.m */, + DF7C1B142319B56E00BE9EF2 /* ViewController.h */, + DF7C1B172319B56E00BE9EF2 /* Main.storyboard */, + DF7C1B1A2319B57300BE9EF2 /* Assets.xcassets */, + DF7C1B1C2319B57300BE9EF2 /* LaunchScreen.storyboard */, + DF7C1B1F2319B57300BE9EF2 /* Info.plist */, + DF7C1B202319B57300BE9EF2 /* main.m */, + ); + path = MSALiOSobjC; + sourceTree = ""; + }; + E1C3514B9C5043504D1805C8 /* Frameworks */ = { + isa = PBXGroup; + children = ( + D0D326DF73C4535704D10F5B /* Pods_MSALiOSobjC.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + DF7C1B0D2319B56E00BE9EF2 /* MSALiOSobjC */ = { + isa = PBXNativeTarget; + buildConfigurationList = DF7C1B242319B57300BE9EF2 /* Build configuration list for PBXNativeTarget "MSALiOSobjC" */; + buildPhases = ( + 432F08323A9DD6E849EBF925 /* [CP] Check Pods Manifest.lock */, + DF7C1B0A2319B56E00BE9EF2 /* Sources */, + DF7C1B0B2319B56E00BE9EF2 /* Frameworks */, + DF7C1B0C2319B56E00BE9EF2 /* Resources */, + 298558DCA24B94CBA543C05A /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = MSALiOSobjC; + productName = objCSample; + productReference = DF7C1B0E2319B56E00BE9EF2 /* MSALiOSobjC.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + DF7C1B062319B56D00BE9EF2 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1020; + ORGANIZATIONNAME = Microsoft; + TargetAttributes = { + DF7C1B0D2319B56E00BE9EF2 = { + CreatedOnToolsVersion = 10.2.1; + SystemCapabilities = { + com.apple.Keychain = { + enabled = 1; + }; + }; + }; + }; + }; + buildConfigurationList = DF7C1B092319B56D00BE9EF2 /* Build configuration list for PBXProject "MSALiOSobjC" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = DF7C1B052319B56D00BE9EF2; + productRefGroup = DF7C1B0F2319B56E00BE9EF2 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + DF7C1B0D2319B56E00BE9EF2 /* MSALiOSobjC */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + DF7C1B0C2319B56E00BE9EF2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DF7C1B1E2319B57300BE9EF2 /* LaunchScreen.storyboard in Resources */, + DF7C1B1B2319B57300BE9EF2 /* Assets.xcassets in Resources */, + DF7C1B192319B56E00BE9EF2 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 298558DCA24B94CBA543C05A /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-MSALiOSobjC/Pods-MSALiOSobjC-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-MSALiOSobjC/Pods-MSALiOSobjC-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MSALiOSobjC/Pods-MSALiOSobjC-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 432F08323A9DD6E849EBF925 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-MSALiOSobjC-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + DF7C1B0A2319B56E00BE9EF2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DF7C1B162319B56E00BE9EF2 /* ViewController.m in Sources */, + DF7C1B212319B57300BE9EF2 /* main.m in Sources */, + DF7C1B132319B56E00BE9EF2 /* AppDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + DF7C1B172319B56E00BE9EF2 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + DF7C1B182319B56E00BE9EF2 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + DF7C1B1C2319B57300BE9EF2 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + DF7C1B1D2319B57300BE9EF2 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + DF7C1B222319B57300BE9EF2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + DF7C1B232319B57300BE9EF2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + DF7C1B252319B57300BE9EF2 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C0ED207111DA16C4540CF929 /* Pods-MSALiOSobjC.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = MSALiOSobjC/MSALiOSobjC.entitlements; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = N9S2V74MEY; + INFOPLIST_FILE = MSALiOSobjC/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.microsoft.identitysample.MSALiOSobjC; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + DF7C1B262319B57300BE9EF2 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 468A646A4BCC93681BB7849C /* Pods-MSALiOSobjC.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = MSALiOSobjC/MSALiOSobjC.entitlements; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = N9S2V74MEY; + INFOPLIST_FILE = MSALiOSobjC/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.microsoft.identitysample.MSALiOSobjC; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + DF7C1B092319B56D00BE9EF2 /* Build configuration list for PBXProject "MSALiOSobjC" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DF7C1B222319B57300BE9EF2 /* Debug */, + DF7C1B232319B57300BE9EF2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + DF7C1B242319B57300BE9EF2 /* Build configuration list for PBXNativeTarget "MSALiOSobjC" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DF7C1B252319B57300BE9EF2 /* Debug */, + DF7C1B262319B57300BE9EF2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = DF7C1B062319B56D00BE9EF2 /* Project object */; +} diff --git a/iOS-ObjC/MSALiOSobjC/AppDelegate.h b/iOS-ObjC/MSALiOSobjC/AppDelegate.h new file mode 100644 index 0000000..85125fb --- /dev/null +++ b/iOS-ObjC/MSALiOSobjC/AppDelegate.h @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. +// All rights reserved. +// +// This code is licensed under the MIT License. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//------------------------------------------------------------------------------ + + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/iOS-ObjC/MSALiOSobjC/AppDelegate.m b/iOS-ObjC/MSALiOSobjC/AppDelegate.m new file mode 100644 index 0000000..a3e21c0 --- /dev/null +++ b/iOS-ObjC/MSALiOSobjC/AppDelegate.m @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. +// All rights reserved. +// +// This code is licensed under the MIT License. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//------------------------------------------------------------------------------ + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + + +@end diff --git a/iOS-ObjC/MSALiOSobjC/Assets.xcassets/AppIcon.appiconset/Contents.json b/iOS-ObjC/MSALiOSobjC/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d8db8d6 --- /dev/null +++ b/iOS-ObjC/MSALiOSobjC/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iOS-ObjC/MSALiOSobjC/Assets.xcassets/Contents.json b/iOS-ObjC/MSALiOSobjC/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/iOS-ObjC/MSALiOSobjC/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iOS-ObjC/MSALiOSobjC/Base.lproj/LaunchScreen.storyboard b/iOS-ObjC/MSALiOSobjC/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..bfa3612 --- /dev/null +++ b/iOS-ObjC/MSALiOSobjC/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS-ObjC/MSALiOSobjC/Base.lproj/Main.storyboard b/iOS-ObjC/MSALiOSobjC/Base.lproj/Main.storyboard new file mode 100644 index 0000000..5f0e89f --- /dev/null +++ b/iOS-ObjC/MSALiOSobjC/Base.lproj/Main.storyboard @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS-ObjC/MSALiOSobjC/Info.plist b/iOS-ObjC/MSALiOSobjC/Info.plist new file mode 100644 index 0000000..6428441 --- /dev/null +++ b/iOS-ObjC/MSALiOSobjC/Info.plist @@ -0,0 +1,56 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + MSALiOSobjC + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleURLTypes + + + CFBundleURLSchemes + + msaldb9191e7-9fa9-41e5-84e6-223298a0e9b2 + + + + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/iOS-ObjC/MSALiOSobjC/MSALiOSobjC.entitlements b/iOS-ObjC/MSALiOSobjC/MSALiOSobjC.entitlements new file mode 100644 index 0000000..0c1aa6e --- /dev/null +++ b/iOS-ObjC/MSALiOSobjC/MSALiOSobjC.entitlements @@ -0,0 +1,11 @@ + + + + + keychain-access-groups + + $(AppIdentifierPrefix)com.microsoft.identitysample.objCSample + $(AppIdentifierPrefix)com.microsoft.adalcache + + + diff --git a/iOS-ObjC/MSALiOSobjC/ViewController.h b/iOS-ObjC/MSALiOSobjC/ViewController.h new file mode 100644 index 0000000..db3eadd --- /dev/null +++ b/iOS-ObjC/MSALiOSobjC/ViewController.h @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. +// All rights reserved. +// +// This code is licensed under the MIT License. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//------------------------------------------------------------------------------ + + +#import + +@interface ViewController : UIViewController + @property (weak, nonatomic) IBOutlet UIButton *signout; + @property (weak, nonatomic) IBOutlet UIButton *callGraph; + @property (weak, nonatomic) IBOutlet UITextView *resultTextView; + +@end + diff --git a/iOS-ObjC/MSALiOSobjC/ViewController.m b/iOS-ObjC/MSALiOSobjC/ViewController.m new file mode 100644 index 0000000..2db892b --- /dev/null +++ b/iOS-ObjC/MSALiOSobjC/ViewController.m @@ -0,0 +1,278 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. +// All rights reserved. +// +// This code is licensed under the MIT License. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//------------------------------------------------------------------------------ + + +#import "ViewController.h" +#import + +/// 😃 A View Controller that will respond to the events of the Storyboard. + +@interface ViewController () + + @end + +@implementation ViewController + + MSALPublicClientApplication *application; + + // Update the below to your client ID you received in the portal. The below is for running the demo only + NSString *clientId = @"db9191e7-9fa9-41e5-84e6-223298a0e9b2"; + // Additional variables for Auth and Graph API + NSString *redirectUri = @"msaldb9191e7-9fa9-41e5-84e6-223298a0e9b2://auth"; + NSString *authorityString = @"https://login.microsoftonline.com/common"; + NSString *graphURI = @"https://graph.microsoft.com/v1.0/me/"; + + /** + Setup public client application in viewDidLoad + */ + + - (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. + [self initMSAL]; + } + + // MARK: Initialization + + -(void) initMSAL{ + + /** + + Initialize a MSALPublicClientApplication with a given clientID and authority + + - clientId: The clientID of your application, you should get this from the app portal. + - redirectUri: A redirect URI of your application, you should get this from the app portal. + If nil, MSAL will create one by default. i.e./ msauth.://auth + - authority: A URL indicating a directory that MSAL can use to obtain tokens. In Azure AD + it is of the form https://, where is the + directory host (e.g. https://login.microsoftonline.com) and is a + identifier within the directory itself (e.g. a domain associated to the + tenant, such as contoso.onmicrosoft.com, or the GUID representing the + TenantID property of the directory) + - error The error that occurred creating the application object, if any, if you're + not interested in the specific error pass in nil. + */ + + NSError *error = nil; + + NSURL *authorityURL = [NSURL URLWithString:(authorityString)]; + + MSALAuthority *authority = [MSALAuthority authorityWithURL:authorityURL error:nil]; + + + MSALPublicClientApplicationConfig *pcaConfig = [[MSALPublicClientApplicationConfig alloc] initWithClientId:clientId + redirectUri:redirectUri + authority:authority]; + + application = [[MSALPublicClientApplication alloc] initWithConfiguration:pcaConfig error:&error]; + + if (application == nil) + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error initializing application" + message:error.description + delegate:self + cancelButtonTitle:@"OK" + otherButtonTitles:nil]; + [alert show]; + + return; + } + } + + - (void)didReceiveMemoryWarning{ + [super didReceiveMemoryWarning]; + } + + /** + This action will invoke the remove account APIs to clear the token cache + to sign out a user from this application. + */ + + - (IBAction)signOut{ + + MSALAccount *account = [self currentAccount]; + if (account == nil){ + return; + } + + /** + Removes all tokens from the cache for this application for the provided account + + - account: The account to remove from the cache + */ + + [application removeAccount:account error:nil]; + _signout.enabled = false; + [_resultTextView setText:@""]; + } + + // MARK: Acquiring and using token + + /** + This will invoke the authorization flow. + */ + + - (IBAction)callGraphAction: (id)sender{ + + MSALAccount *msalAccount = [self currentAccount]; + // We check to see if we have a current logged in account. + // If we don't, then we need to sign someone in. + if (msalAccount == nil){ + [self acquireTokenInteractively]; + return; + } + + [self acquireTokenSilently:msalAccount]; + } + + -(void)acquireTokenSilently: (MSALAccount*) account { + /** + + Acquire a token for an existing account silently + + - forScopes: Permissions you want included in the access token received + in the result in the completionBlock. Not all scopes are + guaranteed to be included in the access token returned. + - account: An account object that we retrieved from the application object before that the + authentication flow will be locked down to. + - completionBlock: The completion block that will be called when the authentication + flow completes, or encounters an error. + */ + NSArray *scopes = @[@"https://graph.microsoft.com/user.read"]; + + MSALSilentTokenParameters *parameters = [[MSALSilentTokenParameters alloc] initWithScopes:scopes account:account]; + + // interactionRequired means we need to ask the user to sign-in. This usually happens + // when the user's Refresh Token is expired or if the user has changed their password + // among other possible reasons. + + [application acquireTokenSilentWithParameters:parameters completionBlock:^(MSALResult *result, NSError *error) + { + if (error != nil){ + if (error.domain == MSALErrorDomain) { + if (error.code == MSALErrorInteractionRequired){ + dispatch_async(dispatch_get_main_queue(), ^{ + [self acquireTokenInteractively]; + return; + }); + } + } + } + + [self updateResultView:result]; + dispatch_async(dispatch_get_main_queue(), ^{ + _signout.enabled = true ; + }); + [self contentWithToken:[result accessToken]]; + }]; + + } + + -(void)acquireTokenInteractively{ + NSArray *scopes = @[@"https://graph.microsoft.com/user.read"]; + MSALInteractiveTokenParameters *parameters = [[MSALInteractiveTokenParameters alloc] initWithScopes:scopes]; + + + void (^completionBlock)(MSALResult *result, NSError *error) = ^(MSALResult *result, NSError *error) { + + dispatch_async(dispatch_get_main_queue(), ^{ + + if (result) + { + [self updateResultView:result]; + dispatch_async(dispatch_get_main_queue(), ^{ + _signout.enabled = true ; + }); + [self contentWithToken:[result accessToken]]; + } + else + { + [self updateResultViewError:error]; + } + + }); + }; + + [application acquireTokenWithParameters:parameters completionBlock:completionBlock]; + } + + /** + This will invoke the call to the Microsoft Graph API. It uses the + built in URLSession to create a connection. + */ + + -(void) contentWithToken:(NSString *)token{ + + // Specify the Graph API endpoint + NSURL *graphURL = [NSURL URLWithString:(graphURI)]; + NSMutableURLRequest *graphRequest = [NSMutableURLRequest requestWithURL:graphURL]; + NSString *authValue = [NSString stringWithFormat:@"Bearer %@", token]; + // Set the Authorization header for the request. We use Bearer tokens, so we specify Bearer + the token we got from the result + [graphRequest addValue:[NSString stringWithFormat:@"Bearer %@", token] forHTTPHeaderField:@"Authorization"]; + + + NSURLSession *session = [NSURLSession sharedSession]; + NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:graphRequest + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + NSLog(@"%@",data); + if (error) + [self updateResultViewError:error]; + else { + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + NSLog(@"%@",json); + dispatch_async(dispatch_get_main_queue(), ^{ + [self.resultTextView setText:[json description]]; + }); + } + }]; + [dataTask resume]; + + } + + -(void) updateResultView: (MSALResult*) result{ + NSString *resultText = [NSString stringWithFormat:@"{\n\taccessToken = %@\n\texpiresOn = %@\n\ttenantId = %@\n\tuser = %@\n\tscopes = %@\n\tauthority = %@\n}", + result.accessToken, result.expiresOn, result.tenantProfile.tenantId, result.account, result.scopes, result.authority]; + [_resultTextView setText:resultText]; + + } + + -(void) updateResultViewError: (NSError*) error{ + NSString *resultErrorText = [NSString stringWithFormat:@"%@", error]; + [_resultTextView setText:resultErrorText]; + } + + // MARK: Get account and removing cache + + -(MSALAccount*) currentAccount{ + NSArray *accounts = [application allAccounts:nil]; + // We retrieve our current account by getting the first account from cache + // In multi-account applications, account should be retrieved by home account identifier or username instead + return [accounts firstObject]; + } + + + @end diff --git a/iOS-ObjC/MSALiOSobjC/main.m b/iOS-ObjC/MSALiOSobjC/main.m new file mode 100644 index 0000000..4cc4aa8 --- /dev/null +++ b/iOS-ObjC/MSALiOSobjC/main.m @@ -0,0 +1,35 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. +// All rights reserved. +// +// This code is licensed under the MIT License. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//------------------------------------------------------------------------------ + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/iOS-ObjC/Podfile b/iOS-ObjC/Podfile new file mode 100644 index 0000000..6b347a8 --- /dev/null +++ b/iOS-ObjC/Podfile @@ -0,0 +1,11 @@ +# Uncomment the next line to define a global platform for your project +# platform :ios, '9.0' + +target 'MSALiOSobjC' do + # Comment the next line if you don't want to use dynamic frameworks + use_frameworks! + + # Pods for MSALiOSobjC + pod 'MSAL', '~> 0.8.0' + +end