Mailcore2: Distingue between thread email with single email on Gmail - mailcore2

I am using mailcore2 lib to build the app on iOS. I am trying to distingue between thread email with single email on Gmail. The purpose is display thread icon for thread email and load all the email in the thread in background.
I fetch message from gmail and have an array of object MCOIMAPMessage. I check the "references" of MCOMessageHeader from MCOIMAPMessage.header
/** References field. It's an array of message-ids.*/
#property (nonatomic, copy) NSArray * /* NSString */ references;
If thread the "references" have some info as
message.header.references = (
"CAH-THaOHPRJ=OZMrhZmFy=7s=sK4HC8TJ+a25UZ9fCcOdcVZ6g#mail.gmail.com",
"CABK6ehzuV18YgoGJvd4Dabch95rmYFLrHhPp_NNvCYAJS0jrmg#mail.gmail.com",
"CAH-THaPTJAK_QPQkexLgRO92DctjTtqexfdkXxQK0_g_oPexKQ#mail.gmail.com",
"CABK6ehyFiQ4j8PmNNyg3bKOJNWS_JsF0BBpmZtGZH35kLFZukQ#mail.gmail.com",
"CAH-THaPv0-RH-da2F5QH7oN21+jCDCRUYBUcH3Fi0mJJyCPoGQ#mail.gmail.com"
)
if single message it will be nil.
Please help to correct or show me the proper way to identify between thread email vs single email.
It is great if we can get the info about how many email in the thread so that we can display the number as gmail app.
Great appreciate mailcore2 team.

Related

Application with CloudKit and Coredata for the local storage. How to cope with the order of CKSubscritpion notifications

Hello I have created a macOS cocoa application that uses Cloudkit, and Coredata to store a local copy of the storage. My application has an 'item' record which stores CKReferences to 'subitems'. The local storage is maintained through the use of CKSubscription notifications that trigger Core Data code for the creation/update of the local objects. The issue is that if I create a new item with subitems and later launch the app on another Mac, it can be that the other copy receives the sub-item creation notification earlier than the item's. Thus the code receives the sub-item but there is no corresponding Core Data object yet available at that point. Does anybody imagine a good pattern to solve this issue ?
Use the sync api. Apple recommends you use subscriptions only to get notified that something has changed not what. When you receive a notification fetch all changes that have been made since the last update.
Apple faces this same issue with the Notes app where they have folders containing notes, and notes containing attachments i.e. they cannot download a note that is in a folder that doesn't exist yet. How they solve it is using a private class CKRecordGraph and the method + (id)topologicallySortRecords:(id)arg1 withError:(id *)arg2; which sorts based on the CKReferences so they ensure they upload the folders before the notes that are inside (i.e. have a reference to the containing folder). Since the client will download the changes in order, it would be impossible for another client to download the note before the folder. You might also want to experiment with placeholder objects so you create the object but then fill in the info later. You could experiment by using the private class and then provide your own basic implementation perhaps customised for your own entities, e.g. always order the parent entities before the children. Here is the header for CKRecordGraph maybe one day it'll be public (I submitted feedback FB6117775 requesting it).
//
// Generated by class-dump 3.5-MH (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import <objc/NSObject.h>
#class NSArray, NSMutableArray;
#interface CKRecordGraph : NSObject
{
NSMutableArray *_nodes;
NSArray *_sortedRecords;
}
#property (strong, nonatomic) NSMutableArray *nodes; // #synthesize nodes=_nodes;
#property (strong, nonatomic) NSArray *sortedRecords; // #synthesize sortedRecords=_sortedRecords;
+ (id)topologicallySortRecords:(id)arg1 withError:(id *)arg2;
- (BOOL)addRecords:(id)arg1 error:(id *)arg2;
- (id)description;
- (id)init;
- (id)recordsByTopologicalSortWithError:(id *)arg1;
#end

Failed to get voip phone information from native phone recents by using CallKit

I integrated CallKit framework to my app, and make an outgoing call.
I can see the outgoing call in native phone recents.
But when I tab the outgoing call and want to get phone info.
It crashed.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSUserActivity interaction]: unrecognized selector sent to instance 0x17d4ab90'
Here is my code in AppDelegate.m
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler NS_AVAILABLE_IOS(8_0)
{
INInteraction *interaction = userActivity.interaction;
INStartAudioCallIntent *startAudioCallIntent = (INStartAudioCallIntent *)interaction.intent;
INPerson *contact = startAudioCallIntent.contacts[0];
INPersonHandle *personHandle = contact.personHandle;
NSString *phoneNumber = personHandle.value;
}
I crashed in INInteraction *interaction = userActivity.interaction;
And I checked with interaction info
#property (readonly, nullable, NS_NONATOMIC_IOSONLY) INInteraction *interaction API_AVAILABLE(macosx(10.12), ios(10.0));
Following are my environment
mac: 10.12.1
xcode: 8.1
iOS: 10.1.1
It doesn't violate the requirement
I search all day but seems no one meet this problem.
Is there anything wrong about code level or have another way to get the phone information?
enter image description here
I have try add NSUserActivity Types bu it not used, I also Use This method sovle This problem.
I can fixed this with adding intents.framework in Target->Build Phases-> Link Binary with Libraries
enter image description here
I hope you missed out NSUserActivityTypes key in info.plist. Below is the key and value to add, based on the intent you are handling,

Send WhatsApp messages automatically with Automate-App

I want to send a WhatsApp message to a specific contact with the Automate-app. How can do I do this?
This is the link to the app:
https://play.google.com/store/apps/details?id=com.llamalab.automate
I know this is pretty late reply.
You can make use of below blocks and build
App start block and choose activity class as
com.whatsapp.ContactPicker
Use Interact blocks for searching, selecting and messaging
Extend with Variable for searching contact and for message text
I have been trying different ways but many of them fall short of full automation.
currently, I am using blocks to send a message to (unsaved) contact. This skips the contactPicker window.
the flow blocks:
[start flow] --> [view content] --> [interact]
that's it!
in view content, you will need to specify the content uri (change number and msg):
https://api.whatsapp.com/send?phone=+966xxxxxxxxx&text=msg
in interact block, specify the (proceed) when element appeared.
the (action) is click.
and (XPATH):
fn:reverse((.//[{("android.widget.ImageButton") = null ? "true()" : "fn:choose(#class,string(#class),name())={"android.widget.ImageButton";xpathEncode}"} and {("com.whatsapp:id/send") = null ? "true()" : "#android:id={"#" ++ ("com.whatsapp:id/send");xpathEncode}"}])[1]/ancestor-or-self::)
that's it.

share text on twitter with consumer key at objective c

i want to post NSString with my consumer key and secret on twitter, using objective c. usually everyone use twitter library which is in xcode. but the library in xcode send without consumer key and secret. so i found a sample code from http://blog.mugunthkumar.com/coding/adding-twitter-support-ios-5-with-oauth-fallback-to-your-ios-app-with-rsoauthengine/
that code is run successfully but i have to convert arc project from Edit/Refactor/Convert to Objective C ARC... menu. when i do this all of my running other codes give error. i just want to send sample text with consumer key and secret. thank you everyone.
you can user sharekit for that
configure ShkConfig file
#define SHKTwitterSecret #"r43dw1kQyCB3AGs1vDai6C7wCxUhQlIIKr0rp5vU"
#define SHKTwitterCallbackUrl #"https://www.google.com"
in your .m file
#import "SHK.h"
#import "SHKTwitter.h"
SHKItem *item = [SHKItem text:#"textmeg"];
[SHKTwitter shareItem:item];
Use sharekit for authentication and sending text message as its easy to use
Download Sharekit from here.When error occurs follow this link

Getting user's default email address in Cocoa

How do I obtain the user's default email address? I need to obtain it for my crash reporter dialog, so the user won't have to fill it out manually.
Never mind, I got it. First, I just have to add AddressBook.framework into my Linked Frameworks. Then, this is the code required:
#import <AddressBook/AddressBook.h>
NSString *theEmailAddressWeWantToObtain = #"";
ABPerson *aPerson = [[ABAddressBook sharedAddressBook] me];
ABMultiValue *emails = [aPerson valueForProperty:kABEmailProperty];
if([emails count] > 0)
theEmailAddressWeWantToObtain = [emails valueAtIndex:0];
From "*Address Book Programming Guide for iOS":
Link the Address Book UI and Address Book frameworks to your project.
Important The project will fail to build (with a linker error) if you do not link against both of these framework.
Linking in the Framework without the UI will prevent the sample code from compiling.