How to get Device Token in iOS 10.0 using swift

Device Token using Swift

How to get Device Token in iOS 10.0 using swift

After getting the error of Device Token older method i just made a logic to get the Device Token and send it to the server via getting this technique Here is a single logic written on swift language in didRegisterForRemoteNotificationsWithDeviceToken delegate method 🙂

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data){
        
        var token = ""
        for i in 0..<devicetoken .count {
            token = token + String(format: "%02.2hhx", arguments: [deviceToken[i]])
        }
        print(token)
        
    }

 

Thanks kindly follow me on twitter for more updates https://twitter.com/mkiosdeveloper

How to send Push Notification in iOS 10.0 using Swift

push notification in ios10

How to send Push Notification in iOS 10.0 using Swift

Hello, Today i gonna teach you how to send push notification in ios 10.0 using swift and xcode 8.0. Apple is very rapidly changing in the technologies as part from the developer they also have to learn to much now a days as considered to before 2014 There development is too slow and changes not come’s too fast. But as per consideration of devices and iOS they must have to changes the UI and UX according to user needs.

For same reason Push Notification is also little bit changed as well I will teach you how to send puch notification in iOS 10.0 using Swift 3.

I am not gonna tell you how to register in device or provisions profile i though you know it very well how to do work with provisioning profile and certificates using apple developer program.

Lets Begin !

After creating the provisioning profile and all the things you can follow step by step then there is zero warning and zero error, there was only 3 step to accomplish the goal successfully. You can open AppDelegate.Swift.

Step#1:

import the header file “UserNotifications” in the top of the AppDelegate.Swift

import UserNotifications

then simple add the “UNUserNotificationCenterDelegate” in the delegate class I know you know that very well but just for the tutorial i can’t skip the main steps.

Example:

class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {

Step#2:

func registerForPushNotifications(application: UIApplication) {
        
        if #available(iOS 10.0, *){
            UNUserNotificationCenter.current().delegate = self
            UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert], completionHandler: {(granted, error) in
                if (granted){
                
                    UIApplication.shared.registerForRemoteNotifications()
                }
                else{
                    // Do the stuff for errors
                    print("Error !")
                }
            })
        }
            
        else{
            //If user is not on iOS 10 use the old methods we've been using
            let notifcationTypes: UIUserNotificationType = [UIUserNotificationType.alert, UIUserNotificationType.badge, UIUserNotificationType.sound]
            
            let notificationSettings = UIUserNotificationSettings(types: notifcationTypes, categories: nil)
            application.registerUserNotificationSettings(notificationSettings)
            
        }

    
    
    }
    
    @available(iOS 10.0, *)
    private func userNotificationCenter(center: UNUserNotificationCenter, willPresentNotification notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -&gt; Void) {
        //Handle the notification
    }
    
    @available(iOS 10.0, *)
    private func userNotificationCenter(center: UNUserNotificationCenter, didReceiveNotificationResponse response: UNNotificationResponse, withCompletionHandler completionHandler: () -&gt; Void) {
        //Handle the notification
    }

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data){
        
        var token = ""
        for i in 0..<devicetoken .count {
            token = token + String(format: "%02.2hhx", arguments: [deviceToken[i]])
        }
        print(token)
        
    }
    
    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error){
        
        print("Error: \(error)")
    }
    
    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]){
        
        print("UserInfo: \(userInfo)")
    }

Step#3:

This is the main delegate function which calls when the app start i know you know that 😛

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -&gt; Bool {
        // Override point for customization after application launch.
        
        registerForPushNotifications(application: application)
        
        return true
    }

Just follow us on twitter: <a href="http://twitter.com/mkiosdeveloper">http://twitter.com/mkiosdeveloper</a>

How to get Device Token in iOS 10 using Swift 3 and Xcode 8

ios-10-mohammadkalim.com

How to get Device Token in iOS 10 using Swift 3 and Xcode 8

 
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data){

var token = ""
for i in 0..&lt;deviceToken.count {
token = token + String(format: "%02.2hhx", arguments: [deviceToken[i]])
}
print(token)
}

 

 

How USB drives formatted in El Capitan to work in Windows 10

How USB drives formatted in El Capitan to work in Windows 10

disk_utility_el_capitan

El Capitan (Mac OS 10.11) rejiggered the stock Disk Utility programme to be more visually pleasing.

However, form no longer meets function because USB drives formatted in El Capitan may not be recognised in Windows 10 even if you use the exFAT file format.

I discovered this when trying to create thumb drives that worked across both operating systems. I had no trouble doing this in previous versions of Mac OS, only in El Capitan.

That’s worked for me.

  1. If open, quit Disk Utility
  2. Start the Terminal utility
  3. Run the following Command: defaults write com.apple.DiskUtility advanced-image-options 1
  4. Relaunch Disk Utility
  5. Format your USB device with MBR Partition (Master Boot Record) and exFAT file system

The command in step 3 seems to activate a function that was previously on by default in previous versions. With Disk Utility put in this state, exFAT-formatted USB devices will now work with OSX and Windows.

how to convert string to float in ios

your_float = [your_string floatValue];

NSLog(@"float value is: %f", your_float);

Get the Client IP-Address using PHP

Get the Client IP-Address using PHP

if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}

Import Excel Data into MySQL in 5 Easy Steps

This is probably nothing new to many, but I spent quite some time to figure it out so I thought I’d post my notes on it.

To import data from Excel (or any other program that can produce a text file) is very simple using the LOAD DATA command from the MySQL Command prompt.

Save your Excel data as a csv file (In Excel 2007 using Save As)
Check the saved file using a text editor such as Notepad to see what it actually looks like, i.e. what delimiter was used etc.
Start the MySQL Command Prompt (I’m lazy so I usually do this from the MySQL Query Browser – Tools – MySQL Command Line Client to avoid having to enter username and password etc.)
Enter this command:
LOAD DATA LOCAL INFILE 'C:\\temp\\yourfile.csv' INTO TABLE database.table FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' (field1, field2);

Done!

Very quick and simple once you know it 🙂

Some notes from my own import – may not apply to you if you run a different language version, MySQL version, Excel version etc…

TERMINATED BY – this is why I included step 2. I thought a csv would default to comma separated but at least in my case semicolon was the deafult
ENCLOSED BY – my data was not enclosed by anything so I left this as empty string ”
LINES TERMINATED BY – at first I tried with only ‘\n’ but had to add the ‘\r’ to get rid of a carriage return character being imported into the database
Also make sure that if you do not import into the primary key field/column that it has auto increment on, otherwhise only the first row will be imported

[Update: I had some trouble getting double quotation marks etc when exporting some Excel data and found a few old but useful Excel export macros in VBA]

[Update: To change the list separator in Excel:
1. First search your Excel file for the character you plan to use so it does not exist somewhere in your data.
2. Go into Windows Control Panel + Regional and Language + Formats Tab click Additional Settings + List separator (Windows 7)]

POD & cocoapods Error in OSX Yosemite – Resolved

Following are the tutorial that will resolve POD & cocoapods issue in OSX Yosemite step by step. Follow eight (8) step by step tutorial it will work 100%.

Step # 1:

Just resolve the error following those steps:

  1. Open Xcode 6
  2. Open Preferences
  3. Click the Locations tab
  4. Change the Command Line Tools version to last Xcode 6.x
  5. Uninstall all Cocoapods (you can not remove executables)

Step  # 2:

Open Terminal

Step # 3:

sudo gem uninstall cocoapods

Step # 4:
If xcode is not installed installed xcodeproject then run the following command in terminal

sudo gem install cocoapods

Step # 5:

pod setup

Step # 6:
goto project directory

~/Desktop/TestProject/

Step # 7:

POD init

Step # 7:
Sample POD File

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

pod 'AFNetworking'
pod 'Facebook-iOS-SDK'
pod 'MD5Digest'
pod 'SDWebImage'
pod 'SDWebImage-ProgressView'
pod 'SSKeychain'
pod 'SVProgressHUD'

Step # 8:

pod install

Please share your opinion and experiences. Thanks for visiting. Follow me over twitter: https://twitter.com/mkiosdeveloper

Get the Best iOS Image Quality and smallest in size

Get the Best iOS Image Quality and smallest in size

Using Image Alpha Lossy on as many images as you can; because it greatly reduces there size and image quality.

If you want to optimize all the images then goto Image Optim, It will remove all the invisible junk and re-compress the data.

ImageOptim is a free app that makes images take up less disk space and load faster.

Following are the methods which is do to get the iOS best Image Quality and Smallest in use:

Step # 1:
Download Image Option.

Step # 2:
Simple drag and drop images or image folder into the ImageOptim Window. They will optimize in place.

Step # 3:
Disable Xcode Conversion:

Xcode for iOS by default converts all PNG images to a non-standard iOS-specific PNG derivative. This format saves iOS devices a trivial conversion step during loading, because it uses premultiplied BGRA instead of RGBA color space. It doesn’t affect rendering speed at all.

If size of assets or loading time is your priority (e.g. you want quicker application startup time and quicker AppStore download), disable Xcode’s conversion:

xcode no-compress

Reset Auto Increment in mysql

How to reset auto increment column in mysql

Simple Query:

ALTER TABLE yourTablename AUTO_INCREMENT = 1