UDID Replacement? - iphone

I know [[UIDevice currentDevice] uniqueIdentifier] is being rejected, I used :
- (NSString *) uniqueDeviceIdentifier{
NSString *macaddress = [[UIDevice currentDevice] macaddress];
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
NSString *stringToHash = [NSString stringWithFormat:#"%#%#",macaddress,bundleIdentifier];
NSString *uniqueIdentifier = [stringToHash stringFromMD5];
return uniqueIdentifier;
}
If my method is not approved by Apple, what method can I get a unique identifier?

This project does something similar to what you're doing: https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5. I believe it is being accepted by Apple for now. To actually answer your question, there is no other (public) way of getting a id that is not only unique but the same for every app. #Vishal's method of using:
+ (NSString *)GetUUID {
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return [(NSString *)string autorelease];
}
and #JeffWolski's method of using:
[[NSUUID UUID] UUIDString];
work if you don't need the device id to be consistant between apps and just need a way to identify that specific device within your own. If you need a device ID that works between apps, you will need to use the devices MAC address either using your code or a open source project.
UPDATE
I just found another solution. You can use [[UIDevice currentDevice] identifierForVendor]. Again, this device id will be unique to your app. http://developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instp/UIDevice/identifierForVendor

This is new in iOS 6. It gives you a UUID that conforms to RFC 4122.
[[NSUUID UUID] UUIDString];

Use this CFUUIDCreate() to create a UUID:
+ (NSString *)GetUUID {
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return [(NSString *)string autorelease];
}
And the UDID is only deprecated in iOS 5.

One thing you could do it use openUDID to replace it.

Related

how to get application list in iPhone [duplicate]

This question already has answers here:
Get list of installed apps on iPhone
(5 answers)
Closed 9 years ago.
I'm new to iOS development, i need small information.how to get all install applications in non jail broken device programatically.
i did googling but i got information "its possible only in non-jailbroken device".
please tell me how to we get list. i wrote below code for that
NSFileManager *manager = [NSFileManager defaultManager];
NSArray *fileList = [manager directoryContentsAtPath:documentsDirectory];
for (NSString *s in fileList)
{
NSLog(s);
}
Note : Your Application will be sand-boxed in any Apple Device and you can only use the information inside that sand-boxed environment. You are not allowed to use information of other Application out side your Application Environment in Non-jailbroken Devices. Apple will reject your app if you will try to use that below code for Non-jailbroken Devices. Use this code for jailbroken Devices only.
Sample Code :
-(NSMutableArray *)desktopAppsFromDictionary:(NSDictionary *)dictionary
{
NSMutableArray *desktopApps = [NSMutableArray array];
for (NSString *appKey in dictionary) {
[desktopApps addObject:appKey];
}
return desktopApps;
}
-(void)installedApp
{
static NSString* const installedAppListPath = #"/private/var/mobile/Library/Caches/com.apple.mobile.installation.plist";
BOOL isDir = NO;
if([[NSFileManager defaultManager] fileExistsAtPath: installedAppListPath isDirectory: &isDir] && !isDir)
{
NSMutableDictionary *cacheDict = [NSDictionary dictionaryWithContentsOfFile: installedAppListPath];
NSDictionary *system = [cacheDict objectForKey: #"System"];
NSMutableArray *installedApp = [NSMutableArray arrayWithArray:[self desktopAppsFromDictionary:system]];
NSDictionary *user = [cacheDict objectForKey: #"User"];
[installedApp addObjectsFromArray:[self desktopAppsFromDictionary:user]];
NSLog(#"installedApp :: %#",installedApp);
}
else
{
NSLog(#"Error..");
}
}
Credit goes to Igor Fedorchuk.
There is also one Library called AppList. You can use it on jailbroken Devices.

How to post video on twitter in iPhone sdk

I am an ios developer,i am working on app in which i needs to send video on twitter.But i searched and found that we can only post link of Video,but cannot post the video itself in iPhone sdk.
Can anyone suggest me what to do,if i need to post video on twitter.
You can use TWRequest class with
- (void)addMultiPartData:(NSData *)data withName:(NSString *)name type:(NSString *)type
I am not sure if uploading video is possible.
More on using TWRequest https://dev.twitter.com/docs/ios/posting-images-using-twrequest
I just suggest you to look over the TwitVid documentation From bellow link:
http://twitvid.pbworks.com/w/page/22556295/FrontPage
UPDATE:
i use this type of logic in 4.3 with shareKit
NSString *urlstr =[YorURL stringByReplacingOccurrencesOfString:#" " withString:#""];
[urlstr retain];
NSString *apiEndpoint = [NSString stringWithFormat:#"http://tinyurl.com/api-create.php?url=%#",urlstr];
[apiEndpoint retain];
NSLog(#"\n\n APIEndPoint : %#",apiEndpoint);
NSString *shortURL = [NSString stringWithContentsOfURL:[NSURL URLWithString:apiEndpoint]
encoding:NSASCIIStringEncoding
error:nil];
[shortURL retain];
NSLog(#"Long: %# - Short: %#",urlstr,shortURL);
NSString *txtShare=[NSString stringWithFormat:#"You watching Your %#",shortURL];
SHKItem *item = [SHKItem text:txtShare];
[SHK setRootViewController:self];
[SHKTwitter shareItem:item];
hope this help you...
Thanks to the uploading media new API, you can share video to twitter. And I have tried it, it works.
Please check this: https://github.com/liu044100/SocialVideoHelper
You just need to call this class method.
+(void)uploadTwitterVideo:(NSData*)videoData account:(ACAccount*)account withCompletion:(dispatch_block_t)completion;
Hope it can resolve your problem.

A strange issue with Address Book programming guide for iOS documentation

I am at a beginner level of iOS programming. I am using Xcode 4.2 with iOS Simulator 5.0.
I am making the quick start tutorial app using iOS documentation Address Book programming Guide and I'm following all the steps of the tutorial but I get a strange error in this code:
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
NSString *name;
name = (NSString *) ABRecordCopyValue(person, kABPersonFirstNameProperty);
self.firstName.text=name;
name=( NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
self.lastName.text=name;
[self dismissModalViewControllerAnimated:YES];
return NO;
}
at line:
name = (NSString *) ABRecordCopyValue(person, kABPersonFirstNameProperty);
I get the error Cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'NSString *' requires a bridged cast
What am I doing wrong here ?
Please check out this link which has been updated with the latest:
NSString* name = (__bridge_transfer NSString*)ABRecordCopyValue(person,
kABPersonFirstNameProperty);
or
NSString* name = (__bridge NSString*)ABRecordCopyValue(person,
kABPersonFirstNameProperty);

How to call itunes from my iphone app with search for a known CD

here is my code:
-(IBAction)itunesBuy:(id)sender{
// NSString *urlString = [[NSString alloc] initWithFormat:#"http://itunes.com/%#/%#", self.artistTerm,self.titleTerm];
NSString *urlString = [[NSString alloc] initWithFormat:#"http://phobos.apple.com/WebObjects/MZSearch.woa/wa/advancedSearchResults?albumTerm=%#", self.titleTerm];
NSLog(#"urlString=%#", urlString);
NSString *escapedValue = [(NSString *)CFURLCreateStringByAddingPercentEscapes(nil,(CFStringRef)urlString,NULL,NULL,kCFStringEncodingUTF8) autorelease];
NSURL *itunesUrl = [NSURL URLWithString:escapedValue];
if (![[UIApplication sharedApplication] openURL:itunesUrl])
NSLog(#"%#%#",#"Failed to open url:",[itunesUrl description]);
}
You can see that I tried the simpler itunes link as well. My understanding was that this won't work on the simulator, but should on the device.
On my iPad and my iPhone, it launches itunes, but then I get an error saying:"Your request could not be completed. This search cannot be performed on this device."
Any help would be appreciated.
Steve
There is no advanced search in device appstore, only in itunes on your Mac/PC.
Try to use the simple search with "itms://phobos.apple.com/WebObjects/MZSearch.woa/wa/search?term=%#".

Finding iPhone Application Identifier Prefix programmatically

Is there any way to find the application identifier prefix in you iPhone application programmatically? Or even just to get the entire Application Identifier string?
I see you can find it by peeking into the "embedded.mobileprovision" file, but is there an easier way? (And I don't think that works if you're running in the simulator)
EDIT: Sorry, what I mean is the identifier PREFIX (10 characters). I've realized though that I don't actually need this, because the rest of the ID is guaranteed to be unique anyway.
The bundle id is stored in the Info.plist of the app bundle as St3fan specified, but you should not grope at the Info.plist directly. Instead, use:
[[NSBundle mainBundle] bundleIdentifier]
You can programmatically retrieve the Bundle Seed ID by looking at the access group attribute (i.e. kSecAttrAccessGroup) of an existing KeyChain item. In the code below, I look up for an existing KeyChain entry and create one if it doesn't not exist. Once I have a KeyChain entry, I extract the access group information from it and return the access group's first component separated by "." (period) as the Bundle Seed ID.
+ (NSString *)bundleSeedID {
NSDictionary *query = [NSDictionary dictionaryWithObjectsAndKeys:
kSecClassGenericPassword, kSecClass,
#"bundleSeedID", kSecAttrAccount,
#"", kSecAttrService,
(id)kCFBooleanTrue, kSecReturnAttributes,
nil];
CFDictionaryRef result = nil;
OSStatus status = SecItemCopyMatching((CFDictionaryRef)query, (CFTypeRef *)&result);
if (status == errSecItemNotFound)
status = SecItemAdd((CFDictionaryRef)query, (CFTypeRef *)&result);
if (status != errSecSuccess)
return nil;
NSString *accessGroup = [(NSDictionary *)result objectForKey:kSecAttrAccessGroup];
NSArray *components = [accessGroup componentsSeparatedByString:#"."];
NSString *bundleSeedID = [[components objectEnumerator] nextObject];
CFRelease(result);
return bundleSeedID;
}
If I understand correctly you are looking for bundle identifier? if you you can get this way.
NSString* appID = [[[NSBundle mainBundle] infoDictionary] objectForKey:#"CFBundleIdentifier"];