I am using robbiehanson/XMPPFramework for my current project, I can send and receive messages to people in my roster, but now I have to implement message delivery status. I know the xep its 0184 and I have also included in my project, I am having difficulty utilizing it.
I read in xep-0184 document that request element must also included in message, so here is my code:
#import "XMPPMessage+XEP_0184.h"
.
.
.
NSXMLElement *body = [NSXMLElement elementWithName:#"body"];
[body setStringValue:messageStr];
NSXMLElement *request = [NSXMLElement elementWithName:#"request" xmlns:#"urn:xmpp:receipts"];
NSXMLElement *message = [NSXMLElement elementWithName:#"message"];
[message addAttributeWithName:#"type" stringValue:#"chat"];
[message addAttributeWithName:#"to" stringValue:[defaults objectForKey:#"chatWith"]];
[message addChild:body];
[message addChild:request];
.
.
.
XMPPMessage *xm = [[XMPPMessage alloc]init];
NSLog(#"..1..%d",[xm hasReceiptRequest]); // Result = 0
NSLog(#"..2..%d",[xm hasReceiptResponse]); // Result = 0
NSLog(#"..3..%#",[xm extractReceiptResponseID]); // Result = (null)
NSLog(#"..4..%#",[xm generateReceiptResponse]); // Result = <message><received xmlns="urn:xmpp:receipts"></received></message>
Please help how do i get a message delivery status.
I think you forgot to add the module itself.
When you want to add an XMPPModule like XMPPMessageDeliveryReceipts you should add it to the XMPPStream object first, then you can use its functions.
Do the following:
// Setup Message Delivery Recipts Object
XMPPMessageDeliveryReceipts* xmppMessageDeliveryRecipts = [[XMPPMessageDeliveryReceipts alloc] initWithDispatchQueue:dispatch_get_main_queue()];
xmppMessageDeliveryRecipts.autoSendMessageDeliveryReceipts = YES;
xmppMessageDeliveryRecipts.autoSendMessageDeliveryRequests = YES;
[xmppMessageDeliveryRecipts activate:xmppStream];
When xmppStream is your main XMPPFramework object.
Hope i helped.
Related
I have an app running, wich worked just fine until iOS11. Among many other things, it sets up EKEvents with recurrence. Those events still copy to the calendar as expected, but without the recurrence. And the recurrence vanishes after saving the event.
Thats how I'm doing it:
EKEventStore *newStore = [[EKEventStore alloc] init];
// define new EKEvent
EKEvent *newEvent = [EKEvent eventWithEventStore:newStore];
newEvent.calendar = [ResourceManager sharedResourceManager].selectedCalendar;
newEvent.allDay = TRUE;
newEvent.startDate = loopNSDate;
newEvent.endDate = loopNSDate;
newEvent.availability = EKEventAvailabilityFree;
EKRecurrenceRule *rule = [[EKRecurrenceRule alloc]
initRecurrenceWithFrequency:EKRecurrenceFrequencyDaily
interval:diensteInPlan
end:end];
NSArray *recurrenceRulesForDate = #[rule];
newEvent.recurrenceRules = recurrenceRulesForDate;
newEvent.title = #"EventTitle";
newEvent.notes = note;
NSError *error = nil;
[newStore saveEvent:newEvent span:EKSpanThisEvent error:&error];
NSLOGging the newEvent before "saveEvent..." shows an event with the correct recurrence. But NSLogging it afterwards shows the same event - but with (nill) as recurrence.
Am I missing something here? Many thanks in advance.
I am trying to get info on all the albums/photos using the PHPhotoLibrary. I barely know objective C, and i've looked at some tutorial/sample but couldn't find everything that I needed.
Here is a link to the sample code I based my code on.
https://developer.apple.com/library/ios/samplecode/UsingPhotosFramework/Introduction/Intro.html#//apple_ref/doc/uid/TP40014575-Intro-DontLinkElementID_2
So far I was able to get the albums name and identifier. And I am getting a list of photos, I am able to get their identifier as well, but not the filename. But if I put a break point in my fonction and look at my PHAsset pointer values, I can see the filename there (inside _filename), but if I try to call the variable with the filename in it, the variable does not exist.
So if anyone can provide a sample code to get all info on albums/photos/thumbnail that would be awesome. Or just getting the filename would be a good help.
Here is the code I have tried so far:
-(void)awakeFromNib{
NSMutableArray *allPhotos = self.getAllPhotos;
for (int x = 0; x < allPhotos.count; x ++)
{
PHAsset *photo = [self getPhotoAtIndex:x];
PHAssetSourceType source = photo.sourceType;
NSString *id = photo.localIdentifier;
NSString *description = photo.description;
NSUInteger height = photo.pixelHeight;
NSUInteger width = photo.pixelWidth;
NSLog(#"Test photo info");
}
}
-(PHAsset*) getPhotoAtIndex:(NSInteger) index
{
return [self.getAllPhotos objectAtIndex:index];
}
-(NSMutableArray *) getAllPhotos
{
NSMutableArray *photos = [[NSMutableArray alloc] init];
PHFetchOptions *allPhotosOptions = [[PHFetchOptions alloc] init];
allPhotosOptions.sortDescriptors = #[[NSSortDescriptor sortDescriptorWithKey:#"creationDate" ascending:YES]];
PHFetchResult *allPhotos = [PHAsset fetchAssetsWithOptions:allPhotosOptions];
PHFetchResult *fetchResult = #[allPhotos][0];
for (int x = 0; x < fetchResult.count; x ++) {
PHAsset *asset = fetchResult[x];
photos[x] = asset;
}
return photos;
}
As you can see, I can get the image height and width, its id, but cannot get the url to it.
I have found a way to get the url of my photo.
-(void)getImageURL:(PHAsset*) asset
{
PHContentEditingInputRequestOptions *options = [[PHContentEditingInputRequestOptions alloc] init];
[options setCanHandleAdjustmentData:^BOOL(PHAdjustmentData *adjustmentData) {
return [adjustmentData.formatIdentifier isEqualToString:AdjustmentFormatIdentifier] && [adjustmentData.formatVersion isEqualToString:#"1.0"];
}];
[asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info)
{
NSURL* url = contentEditingInput.fullSizeImageURL;
}];
}
Filenames in the Photos library are an implementation detail and subject to change. There are various private API for discovering them (or ways to use valueForKey or other public introspection APIs to find where they're hidden), they aren't something to be relied upon. In particular, an asset that's been edited is likely to have a different filename than the original.
What do you need a filename/URL for? If you're just uniquely identifying the asset across launches of your app, use localIdentifier. If you're showing it to the user... why? Something like IMG_0234.jpg vs IMG_5672.jpg has little meaning to the average user.
To fetch the assets in a specific album, use fetchAssetsInAssetCollection:options:. To fetch the album(s) containing a specific asset, use fetchAssetCollectionsContainingAsset:withType:options:. To discover the list(s) of albums, use other APIs on PHAssetCollection and its superclass PHCollection.
I know I can get a plain text version of a message using plainTextRenderingOperationWithMessage: but it's very time consuming. I'm only trying to put together a short message summary. Is there a way to get this from the MCOIMAPMessage/MCOAbstractPart without using plainTextRenderingOperationWithMessages:?
I've got a semi-working solution with the following code but it still seems slow (about 2 seconds for the operation to complete) considering all the data should be contained in MCOIMAPMessage which is fully downloaded. Is this as fast as it gets or am I missing something?
MCOIMAPMessage *m = [NSKeyedUnarchiver unarchiveObjectWithData:self.email.mcomessage];
MCOIMAPFetchContentOperation * op =
[session fetchMessageAttachmentByUIDOperationWithFolder:folder
uid:[m uid]
partID:#"1"
encoding:MCOEncoding8Bit];
[op start:^(NSError * error, NSData * partData) {
NSString *string = [[NSString alloc] initWithData:partData encoding:NSUTF8StringEncoding];
string = [string mco_strippedWhitespace];
if (string.length > 200) string = [string substringToIndex:200];
NSLog(#"String: %#", string);
}];
If I have the following example code:
NSXMLDocument* doc = [[NSXMLDocument alloc] initWithContentsOfURL: [NSURL fileURLWithPath:#"file2.xml"] options:0 error:NULL];
NSXMLElement* root = [doc rootElement];
NSArray* objectElements = [root nodesForXPath:#"//object" error:nil];
NSLog (#"doc - %#", doc);
NSXMLElement *c1 = [objectElements objectAtIndex:0];
NSLog (#"c1 --> %#",[c1 stringValue]);
//creating new element
NSXMLElement *c2 = [NSXMLElement elementWithName:#"value" stringValue:#"object new node"];
[c1 replaceChildAtIndex:0 withNode:c2];
NSLog (#"New doc - %#", doc);
I am trying to get an XML element and change its value to another (c2). The problem is that with the new node replacing, I am getting the element name as well inserted into the XML Document.
So, if I have
<element>old value</element>,
I am now getting:
<element><newElement>new value</newElement></element>
How can I program the code so that
<newElement></newElement>
do not get displayed? Thanks
P.S. Even simpler way of explaining:
Basically, I want to replace an Element with another element. So from
<e1>data1</e1>
I want to have
<e2>data 2</e2>
in its place.
I may be misunderstanding the question but it sounds like you are just trying to make the first element have the second ones attributes? Try something like:
- (void) method {
NSArry* attrs = [c2 attributes];
[c1 setAttributes: attrs];
}
Hope that helps.
I am sending send message request with XML bodyfrom my iphone application
<mailbox-item><recipients><recipient><person path='/people/93619553' /></recipient><recipient><person path='/people/116008244' /></recipient><recipient><person path='/people/96885725' /></recipient></recipients><subject>Message from butterfli</subject><body>Aasd</body></mailbox-item>
But getting this error
++ LinkedIn engine reports failure for connection 3CD3052A-7061-4EA0-8863-5584270B9177
The operation couldn’t be completed. (HTTP error 404.)
Code is
- (RDLinkedInConnectionID *)sendMessage:(NSDictionary *)shareDict {
NSURL* url = [NSURL URLWithString:[kAPIBaseURL stringByAppendingString:#"/v1/people/~/mailbox"]];
NSString *xmlStr = #"<mailbox-item><recipients>";
NSArray *toIdArray = [[shareDict objectForKey:#"privacy"] componentsSeparatedByString:#","];
for (int l=0; l<[toIdArray count]; l++) {
xmlStr = [xmlStr stringByAppendingString:[NSString stringWithFormat:#"<recipient><person path='/people/%#' /></recipient>",
[toIdArray objectAtIndex:l]]];
}
xmlStr = [xmlStr stringByAppendingString:[NSString stringWithFormat:#"</recipients><subject>%#</subject><body>%#</body></mailbox-item>",
#"Message from butterfli",[shareDict objectForKey:#"text_message"]]];
[NSString stringWithFormat:#"<share><comment>%#</comment><content><submitted-url>%#</submitted-url></content><visibility><code>anyone</code></visibility></share>",
[shareDict objectForKey:#"link_msg"],[shareDict objectForKey:#"link"]];
NSData *body = [xmlStr dataUsingEncoding:NSUTF8StringEncoding];
NSLog(#"xmlStr..%#",xmlStr);
return [self sendAPIRequestWithURL:url HTTPMethod:#"POST" body:body];
}
Amit Battan
its not a closed issue before it...
But now the solution is
its done...
Before it I am hardcoded the user id which is shown in the URL of user profile on Web.
But its working ok with id of user which is coming through API ..
But not getting why linkedin user different ids??
as
LinkedIn use unique user IDs for each user/application combination to protect user's privacy. Only the application which originally requested (and got) authentication from the member can use that token to retrieve further information.
http://developer.linkedin.com/thread/3044