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.
Related
I'm creating a Watch app just to display a value on the watch when the user taps on a table view in the iPhone/host app.
I would like to get a notification the value changes on a shared UserDefault. It is shared between WatchKit app and the iOS (host) app, so when the user makes any changes in the host app I'm expecting to get the notification. I've done the following:
When user do some action in application (host app):
NSUserDefaults *shared = [[NSUserDefaults alloc] initWithSuiteName:#"group.app"];
id object = [self.plantsArray objectAtIndex:[self.plantsTable indexPathForSelectedRow].row];
[shared setObject:object forKey:#"data"];
[shared synchronize];
In the Watchkit extension have registered for the notification:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(print) name:NSUserDefaultsDidChangeNotification object:nil];
but unfortunately I'm not getting any notification, has anyone a solution?
I don't think iOS has capability of distributed notifications between app and extension, notifications will not work between both, instead you need to find a way in which both can monitor changes. For example files.
As you already have created group, you can keep a file in the group folder and add a filewatcher in extension, update the file from app, and filewatcher will catch the change, and your work is done.
For filewatcher see code here.
Hope it helps.
Cheers.
Update
Find File watcher Swift version here. Thanks #rivera for adding.
You can try MMWormHole which provides :
a channel between the iOS device and the watch which enables you to send data back and forth between them.
Also provides a way to do Notifications without having to handle the file monitoring by urself.
Using it ,That will be all the code needed to do notifications in ur app
[self.wormhole passMessageObject:#{#"buttonNumber" : #(1)} identifier:#"button"];
[self.wormhole listenForMessageWithIdentifier:#"button"
listener:^(id messageObject) {
self.numberLabel.text = [messageObject[#"buttonNumber"] stringValue];
}];
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 need to add one piece of functionality which relates to local storage when the app loads the first time after its downloaded from the app store. I have developed my app using only using jquerymobile and cordova
What I need is some code to achieve the following
Once the app is downloaded onto the iphone / ipad and its opened the app needs to check for the presence of a local storage value called AppID
If appID value does not exist in local storage the app needs to generate a random AppID that is in the following format xxx-xxx-xxx-xxx-xxx-xxx where the x values can be numbers or characters
The randomly generated AppId then needs to be placed in local storage so that it remains in place even after the iphone is rebooted and is only deleted if the app is deleted from the phone.
On the home page of the App I then need to have the AppID value retrieved from local storage displayed
If anyone can directly me to sample code that achieves the above or has already written code that achieves the above i would be very greatful
Use the following code in delegate class method didFinishLaunchingWithOptions
if ([[NSUserDefaults standardUserDefaults] intForKey:#"appID"]==0)
{
//first time launch
//generate an appID and save
[[NSUserDefaults standardUserDefaults] setInteger:app_id forKey:#"appID"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
else
{
//has launched before or app_id has been saved before, retrieve app_id
app_id=[[NSUserDefaults standardUserDefaults] intForKey:#"appID"]
}
As far as I know localStorage in not persistent with ios. ios can delete localStorage whenever it needs memory. You can just use a database like webSQL to save your app_id and check at the beginning of the app that it is set or not and if set,what it's value.
When I use the Dropbox Datastore API and link to another iOS device, I am not able to get the data in my datastore, but I can get the data in the datastore by using the first iOS device that I set up to use the Datastore API. What could be the problem here?
The code is of course the same that is being run on both devices.
DBAccount * account = [[DBAccountManager sharedManager] linkedAccount];
DBDatastore *dataStore = [DBDatastore openDefaultStoreForAccount:account error:nil];
DBTable *table = [dataStore getTable:#"crane"];
__pastCranes = [InspectionBussiness getRecords:nil DBAccount:account DBDatastore:dataStore DBTable:table];
Thanks for the help guys!
Hey so I figured it out. Somewhere after you link the Dropbox Account to this device you have to add this line. For me it was:
[dataStore sync:nil];
This updated the datastore on my device. Then I could load the cranes.
It's strange though, because it doesn't work immediately. I had to run the app a few times before the updated information appeared in the table view.
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