Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase InstanceId unresolved identifier swift4

I have recently updated My SWIFT applications pod file, And because of that firebase version is now updated to a 5.2. Which now gives me following error while getting a device instance id.

let tokenId = InstanceID.instanceID().token()

error: Use of unresolved identifier 'InstanceID'

Previously this code was working fine and I was getting Application's Instance Id.

Following is content of my pod file.

   # Uncomment the next line to define a global platform for your project
# platform :ios, '11.2'

target 'FirebaseChat' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for FirebaseChat

pod 'Firebase/Database'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
pod 'UnderLineTextField', '~> 2.0'
pod 'Alamofire'
pod 'TCPickerView'
pod 'Toast-Swift', '~> 3.0.1'
pod 'IQKeyboardManagerSwift'
end

Any suggestions will be helpful. Thank You.

like image 780
Deepak Avatar asked Jun 08 '18 12:06

Deepak


2 Answers

You should import FirebaseInstanceID

  import FirebaseInstanceID
like image 93
Karthikeyan M Avatar answered Nov 04 '22 05:11

Karthikeyan M


Firebase made changes for token in FirebaseInstanceID update so now they changed syntaxes to get token

Try this

InstanceID.instanceID().instanceID(handler: { (result, error) in
    if let error = error{
        print("Error fetching remote instange ID(Token): \(error)")
    }else if let result = result{
        print("Remote instance ID token: \(result.token)")

    }
})

and import

import FirebaseInstanceID
like image 6
singh.jitendra Avatar answered Nov 04 '22 07:11

singh.jitendra