 import IMFPush
 import UIKit
 
+
 @objc(CDVMFPPush) class CDVMFPPush : CDVPlugin {
     
+    static let sharedInstance = CDVMFPPush()
+    
     let push = IMFPushClient.sharedInstance()
-    
-    // persist register command callback to use in didRegisterForRemoteNotifications
-    // to be used with registerDevice() js plugin function
-    
-    /*
-    * Registers the device on to the IMFPush Notification Server
+
+    var registerCallbackId: String?
+    var registerCommandDelegate: CDVCommandDelegate?
+    
+    /*
+    * Registers the device with APNs
     */
     func register(command: CDVInvokedUrlCommand) {
         
-        self.commandDelegate!.runInBackground({
+        CDVMFPPush.sharedInstance.registerCallbackId = command.callbackId
+        CDVMFPPush.sharedInstance.registerCommandDelegate = self.commandDelegate
+
+        self.commandDelegate!.runInBackground({
+            
             guard let settings = command.arguments[0] as? NSDictionary else {
                 let message = "Settings Parameter is Invalid."
                 let pluginResult = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAsString: message)

        })
    }
    
    public func didRegisterForRemoteNotifications(deviceToken: NSData) {
        
        push.registerDeviceToken(deviceToken) { (response:IMFResponse!, error:NSError!) -> Void in
            if ((error) != nil) {
                
            }
            else {
                
            }
        }
    }
}
        })
    }
    
    /*
    * Unregisters the device with IMFPush Notification Server
    */
    func unregister(command: CDVInvokedUrlCommand) {
        
        self.commandDelegate!.runInBackground({
            
            self.push.unregisterDevice({ (response:IMFResponse!, error:NSError!) -> Void in
                if (error != nil) {
                    let message = error.description
