Friday, 21 October 2016

Generate New pem File

Generate New pem File



To enable Push Notification for your iOS app, you will need to create and upload the Apple Push Notification Certificate (.pem file) to us so we will be able to connect to Apple Push Server on your behalf.

Step 1: Login to iOS Provisioning Portal, click "Certificates" on the left navigation bar. Then, click "+" button.
enter image description here
Step 2: Select Apple Push Notification service SSL (Production) option under Distribution section, then click "Continue" button.
enter image description here
Step 3: Select the App ID you want to use for your BYO app (How to Create An App ID), then click "Continue" to go to next step.
enter image description here
Step 4: Follow the steps "About Creating a Certificate Signing Request (CSR)" to create a Certificate Signing Request.
enter image description here
To supplement the instruction provided by Apple. Here are some of the additional screenshots to assist you to complete the required steps:
Step 4 Supplementary Screenshot 1: Navigate to Certificate Assistant of Keychain Access on your Mac.
enter image description here
Step 4 Supplementary Screenshot 2: Fill in the Certificate Information. Click Continue.
enter image description here
Step 5: Upload the ".certSigningRequest" file which is generated in Step 4, then click "Generate" button.
enter image description here
Step 6: Click "Done" to finish the registration, the iOS Provisioning Portal Page will be refreshed that looks like the following screen:
enter image description here
Then Click "Download" button to download the certificate (.cer file) you've created just now. - Double click the downloaded file to install the certificate into Keychain Access on your Mac.
Step 7: On your Mac, go to "Keychain", look for the certificate you have just installed. If unsure which certificate is the correct one, it should start with "Apple Production IOS Push Services:" followed by your app's bundle ID.
enter image description here
Step 8: Expand the certificate, you should see the private key with either your name or your company name. Select both items by using the "Select" key on your keyboard, right click (or cmd-click if you use a single button mouse), choose "Export 2 items", like Below:
enter image description here
Then save the p12 file with name "pushcert.p12" to your Desktop - now you will be prompted to enter a password to protect it, you can either click Enter to skip the password or enter a password you desire.
Step 9: Now the most difficult part - open "Terminal" on your Mac, and run the following commands:
cd
cd Desktop
openssl pkcs12 -in pushcert.p12 -out pushcert.pem -nodes -clcerts
Step 10: Remove pushcert.p12 from Desktop to avoid mis-uploading it to Build Your Own area. Open "Terminal" on your Mac, and run the following commands:
cd
cd Desktop
rm pushcert.p12
Now you have successfully created an Apple Push Notification Certificate (.pem file)! You will need to upload this file to our Build Your Own area later on. :)




Friday, 14 October 2016

Privacy-Sensitive Data Permission

Privacy-Sensitive Data Permission



Open the file in your project named info.plist, right click it, opening as Source Code, paste this code below to it. Or you can open info.plist as Property List by default, click the add button, Xcode will give you the suggest completions while typing Privacy - with the help of keyboard ⬆️ and ⬇️.
Remember to write your description why you ask for this authorization, between <string> and </string>:


<!-- 🖼 Photo Library -->
<key>NSPhotoLibraryUsageDescription</key>
<string></string>

<!-- 📷 Camera -->
<key>NSCameraUsageDescription</key>
<string></string>

<!-- 🎤 Microphone -->
<key>NSMicrophoneUsageDescription</key>
<string></string>
<!-- 📍 Location -->
<key>NSLocationUsageDescription</key>
<string></string>

<!-- 📍 Location When In Use -->
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>

<!-- 📍 Location Always -->
<key>NSLocationAlwaysUsageDescription</key>
<string></string>
<!-- 💊 Health Update -->
<key>NSHealthUpdateUsageDescription</key>
<string></string>

<!-- 💊 Health Share -->
<key>NSHealthShareUsageDescription</key>
<string></string>

<!-- ᛒ🔵 Bluetooth Peripheral -->
<key>NSBluetoothPeripheralUsageDescription</key>
<string></string>
<!-- 🎵 Media Library -->
<key>NSAppleMusicUsageDescription</key>
<string></string>
If it does not works, try to ask for the the background authorization:

<key>UIBackgroundModes</key>
<array>
    <!-- something you should use in background -->
    <string>location</string>
</array>

Or go to target -> Capabilities -> Background Modes -> open the background Modes:
enter image description here
then clean your Project, run it.

Here’s a mapping of each of the values in case you need to manually add them to the Info.plist:
  • Bluetooth Sharing – NSBluetoothPeripheralUsageDescription
  • Calendar – NSCalendarsUsageDescription
  • CallKit – NSVoIPUsageDescription
  • Camera – NSCameraUsageDescription
  • Contacts – NSContactsUsageDescription
  • Health – NSHealthShareUsageDescription & NSHealthUpdateUsageDescription
  • HomeKit – NSHomeKitUsageDescription
  • Location – NSLocationUsageDescription, NSLocationAlwaysUsageDescription, NSLocationWhenInUseUsageDescription
  • Media Library – NSAppleMusicUsageDescription
  • Microphone – NSMicrophoneUsageDescription
  • Motion – NSMotionUsageDescription
  • Photos – NSPhotoLibraryUsageDescription
  • Reminders – NSRemindersUsageDescription
  • Speech Recognition – NSSpeechRecognitionUsageDescription
  • SiriKit – NSSiriUsageDescription
  • TV Provider – NSVideoSubscriberAccountUsageDescription


Monday, 10 October 2016

Get Contact & Email ID From Iphone

Get Contact & Email ID From Iphone


1) ADD Framework :

Contacts.Framework
ContactsUI.Framework


2) Write Coding in ViewController.m :


#import "ViewController.h"

#import <Contacts/Contacts.h>
#import <ContactsUI/ContactsUI.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    CNContactStore *store = [[CNContactStore alloc] init];
    [store requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * _Nullable error) {
        if (granted == YES) {
            //keys with fetching properties
            NSArray *keys = @[CNContactFamilyNameKey, CNContactGivenNameKey, CNContactPhoneNumbersKey, CNContactImageDataKey,CNContactEmailAddressesKey];
            NSString *containerId = store.defaultContainerIdentifier;
            NSPredicate *predicate = [CNContact predicateForContactsInContainerWithIdentifier:containerId];
            NSError *error;
            NSArray *cnContacts = [store unifiedContactsMatchingPredicate:predicate keysToFetch:keys error:&error];
            if (error) {
                NSLog(@"error fetching contacts %@", error);
            } else {
                
                NSMutableArray *marrContact=[[NSMutableArray alloc] init];
                [marrContact removeAllObjects];
                
                NSString *phone;
                NSString *fullName;
                NSString *firstName;
                NSString *lastName;
                NSString *emailAddress;
                UIImage *profileImage;
                NSMutableArray *contactNumbersArray=[[NSMutableArray alloc] init];
                
                for (CNContact *contact in cnContacts) {
                    // copy data to my variable .
                    firstName = contact.givenName;
                    lastName = contact.familyName;
                    
                    
                    if (lastName == nil) {
                        fullName=[NSString stringWithFormat:@"%@",firstName];
                    }else if (firstName == nil){
                        fullName=[NSString stringWithFormat:@"%@",lastName];
                    }
                    else{
                        fullName=[NSString stringWithFormat:@"%@ %@",firstName,lastName];
                    }
                    UIImage *image = [UIImage imageWithData:contact.imageData];
                    if (image != nil) {
                        profileImage = image;
                    }else{
                        profileImage = [UIImage imageNamed:@"person-icon.png"];
                    }
                    for (CNLabeledValue *label in contact.phoneNumbers) {
                        phone = [label.value stringValue];
                        NSLog(@"%@",phone);
                        if ([phone length] > 0) {
                            [contactNumbersArray addObject:phone];
                        }
                        NSLog(@"Phone :%@",contactNumbersArray);
                    }
                    for (CNLabeledValue *label in contact.emailAddresses) {
                        emailAddress = label.value;
                        if ([emailAddress length] > 0) {
                            NSLog(@"%@",emailAddress);
                            //                            [emailArray addObject:email];
                        }
                        else
                        {
                            emailAddress=@"";
                        }
                    }
                    NSLog(@"%@",emailAddress);
                    
                    NSDictionary* personDict = [[NSDictionary alloc] initWithObjectsAndKeys: firstName,@"firstname",lastName,@"lastname",phone,@"PhoneNumbers",emailAddress,@"email", nil];
                    NSLog(@"%@",personDict);
                    [marrContact addObject:personDict];
                    NSLog(@"contact %@",marrContact);
                    
                    phone=@"";
                    emailAddress=@"";
                    fullName=@"";
                }
                
                
                NSLog(@"all contact %@",marrContact);
                
                dispatch_async(dispatch_get_main_queue(), ^
                               {
                                   
                                   NSLog(@"%@",marrContact);
                                   if (marrContact.count>0) {
                                       NSMutableArray *marrList=[[NSMutableArray alloc] init];
                                       [marrList removeAllObjects];
                                       for (int i=0; i<marrContact.count; i++) {
                                           if ([[[marrContact objectAtIndex:i] valueForKey:@"email"] length]>0) {
                                               [marrList addObject:[marrContact objectAtIndex:i]];
                                           }
                                       }
                                       if (marrList.count>0) {
                                           // Delete record
                                       }
                                       
                                       //                                       if (marrList.count>0) {
                                       //                                              marrCheck=[[NSMutableArray alloc] init];
                                       //                                              [marrCheck removeAllObjects];
                                       //                                              for (int i=0; i<marrList.count; i++) {
                                       //                                                  [marrCheck addObject:@"N"];
                                       //                                              }
                                       //                                              [tblList reloadData];
                                       //                                       }
                                   }
                                   else{
                                       NSLog(@"No Contact found");
                                   }
                               });
            }
        }
    }];  
    
}






Friday, 7 October 2016

Navigate to any iPhone System Settings

Navigate to any iPhone System Settings



1.- Add URL Types 






2.- Use:

Objective : C 


[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Keyboard/KEYBOARDS"]];


Swift 


UIApplication.sharedApplication().openURL(NSURL(string: "prefs:root=General")!)

List of currently known URLs in the Settings app:



  • prefs:root=General&path=About
  • prefs:root=General&path=ACCESSIBILITY
  • prefs:root=AIRPLANE_MODE
  • prefs:root=General&path=AUTOLOCK
  • prefs:root=General&path=USAGE/CELLULAR_USAGE
  • prefs:root=Brightness
  • prefs:root=General&path=Bluetooth
  • prefs:root=General&path=DATE_AND_TIME
  • prefs:root=FACETIME
  • prefs:root=General
  • prefs:root=General&path=Keyboard
  • prefs:root=CASTLE
  • prefs:root=CASTLE&path=STORAGE_AND_BACKUP
  • prefs:root=General&path=INTERNATIONAL
  • prefs:root=LOCATION_SERVICES
  • prefs:root=ACCOUNT_SETTINGS
  • prefs:root=MUSIC
  • prefs:root=MUSIC&path=EQ
  • prefs:root=MUSIC&path=VolumeLimit
  • prefs:root=General&path=Network
  • prefs:root=NIKE_PLUS_IPOD
  • prefs:root=NOTES
  • prefs:root=NOTIFICATIONS_ID
  • prefs:root=Phone
  • prefs:root=Photos
  • prefs:root=General&path=ManagedConfigurationList
  • prefs:root=General&path=Reset
  • prefs:root=Sounds&path=Ringtone
  • prefs:root=Safari
  • prefs:root=General&path=Assistant
  • prefs:root=Sounds
  • prefs:root=General&path=SOFTWARE_UPDATE_LINK
  • prefs:root=STORE
  • prefs:root=TWITTER
  • prefs:root=General&path=USAGE
  • prefs:root=VIDEO
  • prefs:root=General&path=Network/VPN
  • prefs:root=Wallpaper
  • prefs:root=WIFI
  • prefs:root=INTERNET_TETHERING