How to provide functionality to search groupchat with quickblox - ios

I want to implement a functionality in a chat app by which user will be able to search a group by its unique provided code. I have used quickblox for implementing chat functionality. so please provide me a way to do that functionality with quickblox.

Please check official Document of Quickchat .
SimpleSample-chat_users-ios
They have mention all the detail in their document.
Moreover , Just Download the demo and try to implement.
Group_chat
Before implement Group chat don't forget to read typical setting section.
Typical settings [Functionality in Groupchat]
Authentication: Chat history: you may wish to keep
the archive of all public discussion history which is easily supported
by QuickBlox. Some platforms will also require you to implement abuse
and moderation mechanisms which are also supported both via API and
admin panel. File attachments: typically attachments are not supported
1:1 / IM chat: in many applications you may wish to allow users start
a private communication with other user Friending: QuickBlox supports
friending or adding other users to favourites which you may use in
your application - see also [chat: friending / favourite users lists]
start groupchat with creating Dialogue.
Create_new_group_chat_dialog
QBChatDialog *chatDialog = [[QBChatDialog alloc]
initWithDialogID:null type:QBChatDialogTypeGroup];
chatDialog.name = #"Chat with Bob, Sam, Garry"; //set according to requirement
chatDialog.occupantIDs = #[#(55), #(678), #(22)];
[QBRequest createDialog:chatDialog successBlock:^(QBResponse *response, QBChatDialog *createdDialog) {
} errorBlock:^(QBResponse *response) {
}];
Second step --> Create chatnotification
- (QBChatMessage *)createChatNotificationForGroupChatCreation:(QBDialog *)dialog
{
// create message:
QBChatMessage *inviteMessage = [QBChatMessage message];
NSMutableDictionary *customParams = [NSMutableDictionary new];
customParams[#"xmpp_room_jid"] = dialog.roomJID;
customParams[#"name"] = dialog.name;
customParams[#"_id"] = dialog.ID;
customParams[#"type"] = #(dialog.type);
customParams[#"occupants_ids"] = [dialog.occupantIDs componentsJoinedByString:#","];
// Add notification_type=1 to extra params when you created a group chat
//
customParams[#"notification_type"] = #"1";
inviteMessage.customParameters = customParams;
return inviteMessage;
}
...
for (NSString *occupantID in dialog.occupantIDs) {
QBChatMessage *inviteMessage = [self createChatNotificationForGroupChatCreation:dialog];
NSTimeInterval timestamp = (unsigned long)[[NSDate date] timeIntervalSince1970];
customParams[#"date_sent"] = #(timestamp);
// send notification
//
inviteMessage.recipientID = [occupantID integerValue];
[[QBChat instance] sendSystemMessage:inviteMessage completion:^(NSError * _Nullable error) {
}];
}
You will receive opponent in this delegate .
- (void)chatDidReceiveSystemMessage:(QBChatMessage *)message
{
}
You can implement required functionality in group-chat with abolve link.
Like , Get online users ,Leave group chat dialog , Attachment in group. etc.

Related

TigerText simplest text conversation app

I downloaded TigerText Demo app from here and I opened it in xcode but its a huge app I just need conversation part or that single viewcontorller no need of login because I will pass that hard coded like this.
[[TTKit sharedInstance] loginWithUserId:#"username" password:#"password"
success:^(TTUser *user) {
// Handle login.
} failure:^(NSError *error) {
// Handle failure.
}];
After that there will be only one view where users will see there msgs. no login and not organization views required.
To display messages in 'ConversationViewController' you will first need a TTRosterEntry object (An object that represents a conversation), if you would like to load all TTRosterEntry objects regardless of their organization you can use this api
NSFetchedResultsController *frc = [[TTKit sharedInstance] rosterFetchControllerForAllOrganizationsWithDelegate:self];
NSArray *rostersForAllOrganizations = [frc fetchedObjects];
Once you select a roster you can load 'ConversationViewController'
ConversationViewController *conversation = [GetAppDelegate.storyboard instantiateViewControllerWithIdentifier:#"ConversationViewController"];
conversation.rosterEntry = rosterEntry;
[self.navigationController pushViewController:conversation animated:YES];

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

I coding a iOS app using O365-iOS-Connect to connect my app to Office 365. My app can sign in to 365 account. But i can not find some docs how to Fetch/Create calender.
O365-iOS-Connect
Thanks and sorry for my bad english.
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:
Register your iOS application on Microsoft Application Registration Portal and it will give you a client-id
Install the following pods :
pod 'MSGraphSDK-NXOAuth2Adapter'
pod 'MSGraphSDK'
Go to your ViewController and define :
#property (strong, nonatomic) MSGraphClient *client;
NSString *clientId = #"<you_clientId>"; // GLOBAL to the class
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"]];
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.
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
}];
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
}];
} }];
}
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

Office 365 iOS: Not able to fetch List Items from Office 365 SDK

I have added the announcement app and added few items to it, now i want to fetch the items from my announcement list so I have used the below code
token_Obtained_During_first_time_Login: This is the token that i get when i login for the first time using the acquireTokenWithResource method of ADAuthenticationContext class
- (void)getClientList {
NSString *appToken = [[NSUserDefaults standardUserDefaults]
valueForKey:#"token_Obtained_During_first_time_Login"];
NSString* hostName = #"https://myTenant.sharepoint.com/sites/myApp";
OAuthentication *credentials = [[OAuthentication alloc] initWith:appToken];
ListClient *client = [[ListClient alloc]
initWithUrl:hostName
credentials:credentials];
NSURLSessionTask* task = [client getListItems:#"MyAnnouncements"
callback:^(NSMutableArray *listItems, NSError *error) {
if (error==nil) {
NSLog(#"%#",listItems);
}
}];
[task resume];
}
I have even debugged the 365 code and it provides me the below URL for getListItems: callback method
https://myTenant.sharepoint.com/sites/myApp/_api/lists/GetByTitle('MyAnnouncements')/Items
I have even tried the same using getTokenWith method which comes with the sample code
- (void)getAnnouncementList:(void (^)(ListClient *))callback{
NSString* hostName = #"https://myTenant.sharepoint.com";
[self getTokenWith:hostName :true completionHandler:^(NSString *token) {
OAuthentication *credentials = [[OAuthentication alloc] initWith:token];
callback([[ListClient alloc]initWithUrl:hostName credentials:credentials]);
}];
}
But still no luck i get the list as nil
Please guide on how this can be resolved, I have even verified the rights in the Azure Directory everything seems fine am able to fetch data of one drive, mails and calendar but list is a place where i am stuck.
Every time i call the above code i get the response nil not sure what am passing wrong, my guess is the token.
I resolved this issue by making a change in the apiUrl present in the ListClient.m file of Office 365.
All i did was changed it to
const NSString *apiUrl = #"/sites/mobileApp/_api/web/Lists";
Making the above change did the trick and now i can access all the list data.

Opening a Datastore in iOS Dropbox Sync API 3.0

One of the new features of the 3.0 Datastore API is the ability to use local datastores that will later sync up with Dropbox when the user decides to link your app to Dropbox. I'm wondering how the process of opening datastores differs now.
For example, this is how I currently open a datastore:
DBAccount *account = [[DBAccountManager sharedManager] linkedAccount];
self.store = [DBDatastore openDefaultStoreForAccount:account error:nil];
How do I get a DBAccount without a linked account? Maybe I don't. :)
On that same note, what is the process for opening a datastore with openDefaultStoreForAccount if there is no account present?
I just noticed openDefaultLocalStoreForAccountManager:
Is this how it's used? And does this still work later when there is a linked account?
self.store = [DBDatastore openDefaultLocalStoreForAccountManager:[DBAccountManager sharedManager] error:nil];
I'd appreciate any help. Thanks!
From https://www.dropbox.com/developers/blog/99/using-the-new-local-datastores-feature:
// If the user has linked a Dropbox account for the first time...
if (_justLinked) {
if (_localDatastoreManager && self.account) {
// Perform a one-time migration to move from the local datastore to a remote one.
[_localDatastoreManager migrateToAccount:self.account error:nil];
_localDatastoreManager = nil;
}
}
if (!_store) {
// If there's a linked account, use that.
if ([[DBAccountManager sharedManager] linkedAccount]) {
_store = [DBDatastore openDefaultStoreForAccount:self.account error:nil];
// Otherwise, use a local datastore.
} else {
_store = [DBDatastore openDefaultLocalStoreForAccountManager:[DBAccountManager sharedManager]
error:nil];
}
}

Use Braintree payment api in iOS app

I want to use Braintree API in my iOS app.
My app is used for renting purpose i.e. requester user has to make payment to the owner of asset he wanted for rent.
I have checked following links :
http://www.youtube.com/watch?v=s7GlgBFM20I
https://www.braintreepayments.com/developers
http://www.youtube.com/watch?v=2y8Tsml6JYo
https://www.braintreepayments.com/braintrust/venmo-touch-screencasts-add-one-touch-payments-to-your-app-in-15-minutes
etc.
But I didn't get any idea where to provide receiver's account details using Braintree or Venmo api, For Example we can pass e-mail of receiver in PayPal iOS sdk, and then PayPal pays the amount to the user registered with that e-mail.
The same thing I am searching in Braintree Payment API.
Any help is greatly appreciated.
Thanks in advance.
I am using below code : (Used from a sample code given by braintree)
/* Get called when user pay on Pay button on screen.
User wil see a form for entering his credit card number, CVV and expiration date. */
-(IBAction)payButtonClicked
{
self.paymentViewController =
[BTPaymentViewController paymentViewControllerWithVenmoTouchEnabled:YES];
self.paymentViewController.delegate = self;
[self presentViewController:self.paymentViewController animated:YES completion:nil];
}
// When a user types in their credit card information correctly, the BTPaymentViewController sends you
// card details via the `didSubmitCardWithInfo` delegate method.
//
// NB: you receive raw, unencrypted info in the `cardInfo` dictionary, but
// for easy PCI Compliance, you should use the `cardInfoEncrypted` dictionary
// to securely pass data through your servers to the Braintree Gateway.
- (void)paymentViewController:(BTPaymentViewController *)paymentViewController
didSubmitCardWithInfo:(NSDictionary *)cardInfo
andCardInfoEncrypted:(NSDictionary *)cardInfoEncrypted {
[self savePaymentInfoToServer:cardInfoEncrypted]; // send card through your server to Braintree Gateway
}
// When a user adds a saved card from Venmo Touch to your app, the BTPaymentViewController sends you
// a paymentMethodCode that you can pass through your servers to the Braintree Gateway to
// add the full card details to your Vault.
- (void)paymentViewController:(BTPaymentViewController *)paymentViewController
didAuthorizeCardWithPaymentMethodCode:(NSString *)paymentMethodCode {
// Create a dictionary of POST data of the format
// {"payment_method_code": "[encrypted payment_method_code data from Venmo Touch client]"}
NSMutableDictionary *paymentInfo = [NSMutableDictionary dictionaryWithObject:paymentMethodCode
forKey:#"payment_method_code"];
[self savePaymentInfoToServer:paymentInfo]; // send card through your server to Braintree Gateway
}
#define SAMPLE_CHECKOUT_BASE_URL #"http://venmo-sdk-sample-two.herokuapp.com"
//#define SAMPLE_CHECKOUT_BASE_URL #"http://localhost:4567"
// Pass payment info (eg card data) from the client to your server (and then to the Braintree Gateway).
// If card data is valid and added to your Vault, display a success message, and dismiss the BTPaymentViewController.
// If saving to your Vault fails, display an error message to the user via `BTPaymentViewController showErrorWithTitle`
// Saving to your Vault may fail, for example when
// * CVV verification does not pass
// * AVS verification does not pass
// * The card number was a valid Luhn number, but nonexistent or no longer valid
- (void) savePaymentInfoToServer:(NSDictionary *)paymentInfo {
NSURL *url;
if ([paymentInfo objectForKey:#"payment_method_code"]) {
url = [NSURL URLWithString: [NSString stringWithFormat:#"%#/card/payment_method_code", SAMPLE_CHECKOUT_BASE_URL]];
} else {
url = [NSURL URLWithString: [NSString stringWithFormat:#"%#/card/add", SAMPLE_CHECKOUT_BASE_URL]];
}
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
// You need a customer id in order to save a card to the Braintree vault.
// Here, for the sake of example, we set customer_id to device id.
// In practice, this is probably whatever user_id your app has assigned to this user.
NSString *customerId = [[UIDevice currentDevice] identifierForVendor].UUIDString;
[paymentInfo setValue:customerId forKey:#"customer_id"];
request.HTTPBody = [self postDataFromDictionary:paymentInfo];
request.HTTPMethod = #"POST";
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *body, NSError *requestError)
{
NSError *err = nil;
if (!response && requestError) {
NSLog(#"requestError: %#", requestError);
[self.paymentViewController showErrorWithTitle:#"Error" message:#"Unable to reach the network."];
return;
}
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:body options:kNilOptions error:&err];
NSLog(#"saveCardToServer: paymentInfo: %# response: %#, error: %#", paymentInfo, responseDictionary, requestError);
if ([[responseDictionary valueForKey:#"success"] isEqualToNumber:#1]) { // Success!
// Don't forget to call the cleanup method,
// `prepareForDismissal`, on your `BTPaymentViewController`
[self.paymentViewController prepareForDismissal];
// Now you can dismiss and tell the user everything worked.
[self dismissViewControllerAnimated:YES completion:^(void) {
[[[UIAlertView alloc] initWithTitle:#"Success" message:#"Saved your card!" delegate:nil
cancelButtonTitle:#"OK" otherButtonTitles:nil] show];
[[VTClient sharedVTClient] refresh];
}];
} else { // The card did not save correctly, so show the error from server with convenenience method `showErrorWithTitle`
[self.paymentViewController showErrorWithTitle:#"Error saving your card" message:[self messageStringFromResponse:responseDictionary]];
}
}];
}
I work at Braintree. If you've got more questions or need more help, please reach out to our support team.
The Braintree iOS SDK docs include a quickstart guide, as well as detailed information about the features of the library.
If you're looking for information specifically on how to make payments between users of your app / web site, you should take a look at the marketplace guide and the Venmo APIs.

Resources