I am developing a chat application using XMPPFramework and Openfire as the server. Users of my app are registering themselves in a different server. I use the Openfire server solely for chat communication.
Right now, I have doubts in the architecture of my chat app.
I wish to add a user into Openfire every time a user registers on my server. For this, I have to write a service in my server to insert registered details into Openfire. Is this structure is okay?.
Another question - is it possible to insert/create a user in Openfire server using Objective-C in iPhone?. Does Openfire have any API for this, or do I have to write an external query for this to insert into Openfire database?
If insertion is possible through iPhone app instead of using external service, could anyone provide me a link to the methodology and codes to use?
In-band registration is surely the best way to do this with XMPP.
First check whether initiated xmpstream supports registration via method, 'supportsInBandRegistration'. Basic requirement for registration is that a valid xmpp connection should be present.
If registration is supported, create the below array with elements
NSMutableArray *elements = [NSMutableArray array];
[elements addObject:[NSXMLElement elementWithName:#"username" stringValue:#"userName"]];
[elements addObject:[NSXMLElement elementWithName:#"password" stringValue:[[NSUserDefaults standardUserDefaults] valueForKey:userPassword]]];
and pass through XMPPStream method,
- (BOOL)registerWithElements:(NSArray *)elements error:(NSError **)errPtr
Registration success can be checked with the following delegate method.
- (void)xmppStreamDidRegister:(XMPPStream *)sender
Related
i have configured an app in AWS SNS portal , i want to send device token to AWS SNS service ,
i donwloaded the framework form AWS site, and i managed to find some sample codes to integarte in to my ios App
AmazonSNSClient *snsClient = [[AmazonSNSClient alloc] initWithAccessKey:#"myAccessKey" withSecretKey:#"mySecretKey"];
SNSCreatePlatformEndpointRequest *endpointRequest = [SNSCreatePlatformEndpointRequest new];
endpointRequest.token = [self deviceTokenAsString:newDeviceToken];
endpointRequest.platformApplicationArn = #"myAppARN";
[snsClient createPlatformEndpoint:endpointRequest];
but unfortunatly that framework doesnt contains these classes , is thr any framework for me to integrate, does anyone got a tutorial to this
download AWS sdk and in that folder find messageboard.h and messageboard.m file and put both file in that project which you work now.
then which class use you want to SNS function in .m file and appdelegate.m file write this line. #import "MessageBoard.h"
now when you want to send device token to AWS SNS service there write some code:
[[MessageBoard instance] createApplicationEndpoint:replace here user name which you want to send there];
now open messageboard.h file and go createApplicationEndpoint method.
in this method enter your device token.
endpointARN = endpointResponse.endpointArn;
[[NSUserDefaults standardUserDefaults] setObject:endpointARN forKey:#"DEVICE_ENDPOINT"];
[[NSUserDefaults standardUserDefaults] synchronize];
I hope it will help.
I'm currently developing a small chat application using iOS and XMPPFramework.
I registered two users on a XMPP client on a public XMPP server.
However, when I send messages to the bare JIDs via my iOS app, users connected on the app would not receive the message because the XMPP client had sent a presence with a higher priority.
To fix that, I just have the users send their presence with the highest priority, so that when I send a message to their bare JID, the messages are routed to the proper resource. However, I feel like this is not a good way to go about it. I would like to send the message directly to the full JID, but I'm not sure how to get it.
What is the proper way to send or receive the full JID of a user without subscribing? Is it possible or is it just bad practice? Am I supposed to send it in the presence?
AppDelegate.h
+ (AppDelegate*)instance;
AppDelegate.m
+ (AppDelegate*)instance {
return (AppDelegate*)[[UIApplication sharedApplication] delegate];
}
Then in your ViewController.m
XMPPJID *myJID = [[AppDelegate instance] xmppStream].myJID;
This will give you the full JID. Hope this is what you asked.. let me know if not or anything else regarding this.
I want to know that is it possible to create a chatroom and invite people ? I have setup ejabberd on my mac and implemented chat with single buddy following
this link but i want to implement MUC. I tried demo project of MUC which come with xmppframework available here ,but every time i get error 404 remote server not found. The delegate method
- (void)xmppRoomDidCreate:(XMPPRoom *)sender;
never gets called.
Instead
- (void)handleDidLeaveRoom:(XMPPRoom *)room
this method gets called. Has anyone successfully implemented MUC using localhost as server?If yes then please let me know the XMPP client you are using , because for ejabberd,it says remote server not found.
Did you try with conference.host (presumably conference.localhost) as MUC host ?
I am writing an iOS app with a Rails API backend. The Rails backend will serve JSON data to the app. I have the following requirements.
The app will be a free download
The app will show data on a map
The app will show data in the vicinity of the user
Upon loading the app the device should send some unique identifier to the server identifying itself as a device that is running this app.
There will be no authentication for the user as it is not required. The data is available to anyone who downloads the app. All the server needs to know is that the client is a device running the app. The server cannot serve data to any other client
I would like to run the data using SSL between the device and server
The user location will be sent to the server and the server returns the corresponding pieces of data that are in the vicinity of the user
The client receives the JSON and caches the data locally.
Question: Given these requirements, how to set up steps 4 & 5?
Also: If I want to search more on this topic what keywords should I be googling for?
Consider using OpenUDID or SecureUDID.
I give you 2 options.
First of all, the easy way. From some time, apple forbids access to the device ID. However, they give you a device token instead.
To get this unique token, the user must register for remote notification.
Upon application launching, call the following function:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
Then this callback will be called:
- (void)application:didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken.
Send the token to your server and you're done. Problems with this approach are obvious. Your user will have to register for remote notification.
Another approach is to use the MAC address of the wi-fi board.
To do this:
IPAddress.h
IPAddress.c
Import this files into your project.
Then use this function:
InitAddresses();
GetHWAddresses();
for (int i=0; i<MAXADDRS; ++i)
{
//There is a way you can obtain more info about the hw_addrs, but in general, it's the first.
NSLog(#"MAC: %s", hw_addrs[i]);
}
FreeAddresses();
Create a hash using the mac address above and you're done.
Hope it helps.
Upon first launch, the app sends a request to the server saying Hi, I'm a new client, give me an id! The server generates a new, random id and sends it back. The app saves the id locally and uses it henceforth to uniquely identify itself.
I am working on a simple application in which I need send sms programmatically to my friends.
so write below code for sending sms .
MFMessageComposeViewController *picker = [[[MFMessageComposeViewController alloc] init]autorelease];
if([MFMessageComposeViewController canSendText])
{
picker.messageComposeDelegate = self;
picker.recipients =[NSArray arrayWithObject:#"123"];
picker.body=#"hello";
[self presentModalViewController:picker animated:YES];
}
but I do not want to load message picker and send sms to friends.
// [self presentModalViewController:picker animated:YES];
is it possible to send sms without click in send button.
The two options available in the iOS API are:
MFMessageComposeViewController - requires user confirmation
sms:// URLs - requires user confirmation
If you want to do something else, you'll need to set up a network-based service with an SMS gateway provider and send messages via that. I used to work with such a provider that had an HTTP POST interface, which would be simple enough to use. That comes with a couple of important differences:
the SMS is actually sent by the gateway server, not the handset (though you can usually rewrite the sender ID and get the message billed to the handset owner)
you'll need to pay for access to the service, which might include paying per message (or more likely per 1,000 messages)
Also note that sending SMS on your users' behalf without confirmation might be frowned upon when your app is reviewed, especially if they're billed for.