How to Fetch/Create calender by O365-iOS-Connect?

2 Solutions Collect From Internet About “How to Fetch/Create calender by O365-iOS-Connect?”

we have a couple options in our GitHub code samples that might be of assistance.

One is called O365-iOS- Snippets: https://github.com/OfficeDev/O365-iOS-Snippets. The O365 iOS Snippets project shows you how to do basic operations against the Calendar, Contacts, Mail, and Files service endpoints in Office 365.

For Microsoft Graph, we’ve also created an iOS snippets project for that – https://github.com/OfficeDev/O365-iOS-Microsoft-Graph-Snippets. This sample shows how to use Microsoft Graph to send email, manage groups, and perform other activities with Office 365 data.

Hope this helps!

Freya H, The Office Newsroom

Steps to fetch outlook calendars in iOS are:

I use MSGraph SDK & Azure AD v2.0 endpoint(for personal login)

Note: You must know how to install pods and check this link for details: https://graph.microsoft.io/en-us/

Steps:

  1. Register your iOS application on Microsoft Application Registration Portal and it will give you a client-id

  2. Install the following pods :

     pod 'MSGraphSDK-NXOAuth2Adapter'
    
     pod 'MSGraphSDK'
    
  3. Go to your ViewController and define :

    @property (strong, nonatomic) MSGraphClient *client;
    
    NSString *clientId = @"<you_clientId>"; // GLOBAL to the class
    
  4. Now import these files as:

    #import <MSGraphSDK/MSGraphSDK.h>
    
    #import <MSGraphSDK-NXOAuth2Adapter/MSGraphSDKNXOAuth2.h>
    

    5.On your button click: First you have use your client-id and define your permissions in the scope as:

    [NXOAuth2AuthenticationProvider setClientId:clientId
                                     scopes:@[@"https://graph.microsoft.com/Files.ReadWrite",
                                              @"https://graph.microsoft.com/Calendars.ReadWrite"]];
    
  5. Now you have to authenticate with your login details and Microsoft login screen automatically opens up:

    [[NXOAuth2AuthenticationProvider sharedAuthProvider] loginWithViewController:nil completion:^(NSError *error) {
    if (!error) {
        [MSGraphClient setAuthenticationProvider:[NXOAuth2AuthenticationProvider sharedAuthProvider]];
        self.client = [MSGraphClient client];
        //Authenticated successfully
    }  }];
    

If there is no error, then error is nil and it will logged in successfully.

  1. Now we can use different APIs using MSGraphClient and for calendars list:

    [[[[self.client me] calendars] request] getWithCompletion:^(MSCollection *response, MSGraphUserCalendarsCollectionRequest *nextRequest, NSError *error) {
    
           NSArray *calendars = response.value;
          // Here we are getting calendars
       }];
    
  2. Now, get calendars button action look like this:

    - (IBAction)getCalendars:(id)sender {
    
    [NXOAuth2AuthenticationProvider setClientId:clientId
                                         scopes:@[@"https://graph.microsoft.com/Files.ReadWrite",
                                               @"https://graph.microsoft.com/Calendars.ReadWrite"]];
    
    [[NXOAuth2AuthenticationProvider sharedAuthProvider] loginWithViewController:nil completion:^(NSError *error) {
    if (!error) {
        [MSGraphClient setAuthenticationProvider:[NXOAuth2AuthenticationProvider sharedAuthProvider]];
        self.client = [MSGraphClient client];
    
    
        [[[[self.client me] calendars] request] getWithCompletion:^(MSCollection *response, MSGraphUserCalendarsCollectionRequest *nextRequest, NSError *error) {
    
            NSArray *calendars = response.value;
           // Here we are getting calendars
        }];
    } }]; 
    }