Breaking News
Home / iOS / iOS Snippets (page 10)

iOS Snippets

How to get Device token when registered for PushNotification in iOS?

Solution  – (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {     NSLog(@"My token is: %@", deviceToken);               NSString * deviceTokenString = [[[deviceToken description]                                  stringByTrimmingCharactersInSet:[NSCharacterSetcharacterSetWithCharactersInString:@"<>"]]                 …

Read More »

How to convert Device ID as NSData to NString in IOS?

Solution  (NSString *)convertTokenToDeviceID:(NSData *)token {  NSMutableString *deviceID = [NSMutableString string];  // iterate through the bytes and convert to  hexunsigned char *ptr = (unsigned char *)[token bytes];    for (NSInteger i=0; i < 32; ++i) {   [deviceID appendString:[NSString stringWithFormat:@"%02x", ptr[i]]];  }     return deviceID; } [pb_builder]

Read More »

How to check if LBS is enabled in IOS?

Snippet BOOL locationServicesEnabled; CLLocationManager locationManager = [CLLocationManager new]; if( [locationManager respondsToSelector:@selector(locationServicesEnabled) ] ) {     locationServicesEnabled = [locationManager locationServicesEnabled]; } else {     locationServicesEnabled = locationManager.locationServicesEnabled; } [pb_builder]

Read More »

How can I get iPhone Device information via API?

Solution The device information attributes is available in iOS using the UIDevice class NSString    *name;    // e.g. “mvohra iPhone” NSString    *model;             // e.g. @”iPhone”, @”iPod Touch”, @”iPad” NSString    *localizedModel;    // localized version of model NSString    *systemName;        // e.g. @”iPhone OS” NSString    *systemVersion;     // e.g. @”3.0″,@”4.2″ UIDeviceOrientation orientation;       // return current …

Read More »