share text on twitter with consumer key at objective c - 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

Related

How to make Xcode recognise Objective-C commands in order to connect to Firebase?

Newbie here. In short: I'm using Arduino to count how many cars enter my garage and have the data sent to firebase. I was able to connect/read/write using Swift 4. Therefore, I decided to install a pod this one to improve the design of the app. The pod is written in objective-C (I've never used the language), so I thought it would be easier to have the firebase in the same class and language as the pod.
Since I have some code written in Swift 4, I decided to create a bridging header in order to "mix and match" both languages in the same project.
Therefore, the issues I am currently facing are:
1 - In the LMViewController.m file I've added:
#import Firebase;
#import FirebaseDatabase;
along with this code inside - (void)viewDidLoad method:
[FIRApp configure];
#property (strong, nonatomic) FIRDatabaseReference *ref;
self.ref = [[FIRDatabase database] reference];
This code automatically raises red flags due to the fact that it is not recognising it. I am using the code exactly as specified on google's firebase website. Firebase for ios.
2 - I have also tried to add the import FirebaseDatabase within swift appDelegate. No success in the .m file tho.
I would appreciate your help in order to understand how can I make xcode not give me errors when creating a firebase reference in order to read from it and assign the value to the pod code.

How to perform apprequest using native dialogs

We are living confusing times were documentation from the past merges with documentation from the present.
I am trying to make an app request, I have FB SDK 3.1 and iOS6.
I am checking code from the address:
https://developers.facebook.com/docs/howtos/send-requests-using-ios-sdk/
I can not make it work, takes my attention the next paragraph:
In your app delegate import the Facebook.h header file and replace the Facebook framework
"FacebookSDK/FacebookSDK.h" import declaration: #import "Facebook.h"
I don't have Facebook class anymore in my libraries.
Facebook class had to be initialized with app id, delegate, etc... I don't know how it is supposed to work now, specialy having FBSession in place.
My question is, how to make a modern apprequest? And... what is with the documentation?
You can only get the requests dialog with the previous API, it's not available for the current one.
Make sure you follow this step from the docs -
The headers can be found here ~Documents/FacebookSDK/FacebookSDK.framework/Versions/A/DeprecatedHeaders. Drag the whole DeprecatedHeaders folder and deselect the ''Copy items into destination group's folder (if needed)'' option to add the headers as a reference.
Add those headers to your project and you'll have access to the Facebook class.

How to create Apple mail plugin

I'm going to create a mail plugin for the OS X Mail.app application for some additional features.
I have no idea where to start as there is no official documentation for plugins.
Can anyone please help me, how can I start the project.
Is there any initial link or tutorial, please suggest?
As noted, writing Apple Mail plugins is not straightforward, since it only has a private plugin API, which is entirely undocumented and can change with any new version of Mail.app. The best code example is GPGMail, which is open source & still active (already working on Yosemite support). Here is what I successfully did to get started (will put it up on github once finished):
How to build a minimal Apple Mail plugin (as of Mavericks & Xcode 6.0.1)
you need to create an OSX "Bundle" project in XCode
wrapper extension is mailbundle (under Packaging in the project Build settings)
a bundle needs to be stored under ~/Library/Mail/Bundles (as Build Phase add a Copy Files action with that as absolute path destination and the *.mailbundle from your build/ folder as item to copy)
for development, I have set up /Applications/Mail.app as executable in my run scheme, so that Run in XCode will build it, copy the bundle and start mail; note that at this point you'll get an error from Mail that your plugin cannot be started and was disabled
you need to provide a list of SupportedPluginCompatibilityUUIDs in the Info.plist, I stole it from GPGMail, these change with new Mail/OSX versions
use class-dump to generate the header files from Mail.app's private API
starting point is MVMailBundle, which you have to inherit from and which has a registerBundle method to hook you in
I extracted that from the huge generated header file in a small MVMailBundle.h header to include where needed (as done by GPGMail)
create a new class MyMailBundle, inheriting from NSObject
it needs an initialize method
and set it as "Principle class" in the Info.plist so that it gets run when the bundle is loaded by Mail.app
#import <Cocoa/Cocoa.h>
#interface MyMailBundle : NSObject
+ (void)initialize;
#end
initialize implementation: previously, you could use the simple way and directly inherit as done in Letterbox, however, since 64-bit runtimes of Objective-C you have to use the dynamic way as done by GPGMail:
using NSClassFromString to dynamically get the MVMailBundle class
and class_setSuperclass from <objc/runtime.h> to have your own class inherit from it
and then call registerBundle on it casted as MVMailBundle (requires include of MVMailBundle.h)
#import <objc/runtime.h>
#import "MVMailBundle.h"
#import "MyMailBundle.h"
#implementation MyMailBundle
+ (void)initialize
{
NSLog(#"Loading MyMail plugin...");
// since 64-bit objective-c runtimes, you apparently can't load
// symbols directly (i.e. through class inheritance) and have to
// resort to NSClassFromString
Class mvMailBundleClass = NSClassFromString(#"MVMailBundle");
// If this class is not available that means Mail.app
// doesn't allow plugins anymore or has changed the API
if (!mvMailBundleClass)
return;
// dynamically change super class hierarchy
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
class_setSuperclass([self class], mvMailBundleClass);
#pragma GCC diagnostic pop
// register our plugin bundle in mail
[[((MyMailBundle *)self) class] registerBundle];
NSLog(#"Done registering MyMail plugin.");
}
#end
add some NSLog logging calls to verify the right thing is happening, they'll be visible in XCode's console when running/debugging Mail.app from within XCode or alternatively in the system logs of Console.app
This should successfully run the plugin in Mail with no error!
The next steps involve crazy things like MethodSwizzling and ClassPosing to modify Mail's behavior, where GPGMail can be a helpful example. (Haven't been there myself yet)
For reference, here are some of the resources that helped me:
GPGMail
Adam Nash: Getting Ready to Write an Apple Mail.app Plug-in for Mac OS X - some good links, but apparently he never finished the project, so no code
James R. Eagan: Demystifying Mail.app Plugins on Leopard - using PyObjC to write a plugin in Python, explains the basic mechansims, very useful
Aaron Harnly: Mail Plugin Template - for XCode 2 I think, unfortunately the template (download a zip) doesn't work as template in Xcode anymore, but the code is still useful to look at
Aaron Harnly: Letterbox sources - from the same guy, but also from 2007, very outdated; contains a readme from the template, though it doesn't really help if you can't use the template.
There is no official supported way to build such a tool - you need to start trying to hook in to Mail.app without any official support.
If you want to persist on this sort of thing, then you'll need to understand how Mail.app internals work, which is a bunch of using the debugger and class dump to inspect libraries in other apps:
https://github.com/nygard/class-dump
You'll probably also want a way to inject code into other applications, for example:
https://github.com/rentzsch/mach_inject
And every time Apple update Mail.app you'll potentially need to redo everything :)

Add google Plus api and youTube api in objective c at the same time

I am working on a project in which I have to add google plus and youtube api's for iOS. The issue I am facing is that it gives some duplication error while linking:
duplicate symbol _kCharsToForceEscape
and the files it show redundant are:
GDataUtilities.o and GTLUtilities.o
Any kind of help will be appreciated.
Thank you
I have had the same issue, and you can't delete Gdata utilities or GLT Utility because they are called in almost every case in GDATA and the GLT. there is a way around this go to gdata utilities and go down to the part where it says #pragma mark string encoding look for this line of code:
const CFStringRef kCharsToForceEscape = CFSTR("!*'();:#&=+$,/?%#[]");
comment this out.
Then comment this part out:
//CFStringRef escapedStr;
//escapedStr = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
// originalString,
// leaveUnescaped,
// kCharsToForceEscape,
// kCFStringEncodingUTF8);
// if (escapedStr) {
// resultStr = [(id)CFMakeCollectable(escapedStr) autorelease];
// }
If will be in there twice make sure you comment both out.
Then run app.
It worked for me I seem to have youtube working and it seems to compile the google plus API OK.

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.