Coder Social home page Coder Social logo

microsoftgraph / ios-swift-snippets-sample Goto Github PK

View Code? Open in Web Editor NEW
14.0 11.0 14.0 1.42 MB

Please see https://github.com/microsoftgraph/msgraph-training-ios-swift for a Swift sample.

License: MIT License

Swift 97.77% HTML 1.56% Ruby 0.16% Shell 0.51%
devxsample

ios-swift-snippets-sample's Introduction

Microsoft Graph iOS Swift Snippets Sample

Table of contents

Introduction

This sample contains a repository of code snippets that show how to use the Microsoft Graph SDK to send email, manage groups, and perform other activities with Office 365 data. It uses the Microsoft Graph SDK for iOS to work with data returned by Microsoft Graph.

This repository shows you how to access multiple resources, including Microsoft Azure Active Directory (AD) and the Office 365 APIs, by making HTTP requests to the Microsoft Graph API in an iOS app.

These snippets are simple and self-contained, and you can copy and paste them into your own code, whenever appropriate, or use them as a resource for learning how to use the Microsoft Graph SDK for iOS.

Note: If possible, please use this sample with a "non-work" or test account. The sample does not always clean up the created objects in your mailbox and calendar. At this time you'll have to manually remove sample mails and calendar events. Also note that the snippets that get and send messages and that get, create, update, and delete events won't work with all personal accounts. These operations will eventually work when those accounts are updated to work with the v2 authentication endpoint.

Prerequisites

This sample requires the following:

  • Xcode version 10.2.1
  • Installation of CocoaPods as a dependency manager.
  • A Microsoft work or personal email account such as Office 365, or outlook.com, hotmail.com, etc. You can sign up for an Office 365 Developer subscription that includes the resources that you need to start building Office 365 apps.

Register and configure the app

  1. Open a browser and navigate to the Azure Active Directory admin center and login using a personal account (aka: Microsoft Account) or Work or School Account.

  2. Select Azure Active Directory in the left-hand navigation, then select App registrations under Manage.

  3. Select New registration. On the Register an application page, set the values as follows.

    • Set Name to Swift Snippets Sample.
    • Set Supported account types to Accounts in any organizational directory and personal Microsoft accounts.
    • Under Redirect URI, change the drop down to Public client (mobile & desktop), and set the value to msauth.com.microsoft.Graph-iOS-Swift-Snippets://auth.
  4. Choose Register. On the Swift Snippets Sample page, copy the value of the Application (client) ID and save it, you will need it in the next step.

Build and debug

  1. Clone this repository

  2. Open Terminal and navigate to the root of the project. Run the following command to install dependencies.

    pod install
  3. Open Graph-iOS-Swift-Snippets.xcworkspace in Xcode.

  4. Open ApplicationConstants.swift. Replace ENTER_CLIENT_ID with the application ID you got from registering your app.

    // You will set your application's clientId
    static let clientId = "ENTER_CLIENT_ID"
  5. Run the sample.

Running the sample

When launched, the app displays a list of common user tasks. These tasks can be run based on account type and permission level, and are noted in comments:

  • Tasks that are applicable to both work or school and personal accounts, such as getting and sending email, creating files, etc.
  • Tasks that are only applicable to work or school accounts, such as getting a user's manager or account photo.
  • Tasks that are only applicable to a work or school account with administrative permissions, such as getting group members or creating new user accounts.

Select the task that you want to perform and click on it to run. Be aware that if you log in with an account that doesn't have applicable permissions for the tasks you've selected they'll fail. For example if try to run a particular snippet, like get all tenant groups, from an account that doesn't not have admin privileges in the org the operation will fail. Or, if you log in with a personal account and attempt to get the manager of the signed in user, it will fail.

Contributing

If you'd like to contribute to this sample, see CONTRIBUTING.MD.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Copyright

Copyright (c) 2016 Microsoft. All rights reserved.

ios-swift-snippets-sample's People

Contributors

andrewjmay avatar antrix1989 avatar bmitchell287 avatar jackson-woods avatar jasonjoh avatar lindalu-msft avatar nokafor avatar o365devx avatar officegsx avatar ricalo avatar unpluggedk avatar v-dobr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ios-swift-snippets-sample's Issues

Stuck in "We're taking you to your organization's sign-in page"

I'm trying out the sample with a O365 tenant behind an on-premise ADFS so the expectation is that the login view should redirect to the organization's sign-in page, but instead it gets stuck at the screen that says "We're taking you to your organization's sign-in page".

The Android sample works just fine with the same O365 tenant so I am sure the problem is not at the on-premise ADFS side.

Upload large files to one drive swift

i just want to upload large file now it take only less than 10 mb size files to upload. createUploadSession need to add for uploading large files. I couldn't find the right solution and for showing the progressBar. If you give the sample for that it will be great help.

MSAL Failure

Device: IPhone 7 Plus
iOS 13.1
Xcode 11
Log:
Error Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=2 "Cannot start ASWebAuthenticationSession without providing presentation context. Set presentationContextProvider before calling -start." UserInfo={NSDebugDescription=Cannot start ASWebAuthenticationSession without providing presentation context. Set presentationContextProvider before calling -start.}
Failed with internal MSAL error Error Domain=MSALErrorDomain Code=-50000 "(null)" UserInfo={MSALErrorDescriptionKey=Failed to start an interactive session, MSALInternalErrorCodeKey=-50000, MSALCorrelationIDKey=18F986A3-1E8F-4496-B361-DA226475AEB9}
Error: Error Domain=MSALErrorDomain Code=-50000 "(null)" UserInfo={MSALErrorDescriptionKey=Failed to start an interactive session, MSALInternalErrorCodeKey=-50000, MSALCorrelationIDKey=18F986A3-1E8F-4496-B361-DA226475AEB9}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.