Reading IMSI in 3rd Edition
Article Metadata
Tested with
Devices(s): E61i
Compatibility
Platform(s): S60 3rd Edition
Platform Security
Signing Required: DevCert
Capabilities: ReadDeviceData
Article
Keywords: CTelephony::GetSubscriberId()
Created: symbianyucca
(20 Mar 2007)
Last edited: hamishwillee
(11 Jan 2012)
CImsiReader example illustrates how to read IMSI (SIM card's identity number, which has nearly nothing to do with the MSISDN that is the phone number used for calling) in 3rd Edition Symbian devices. Note that this code will most likely not work in the emulator, thus you should only use it in real devices.
Link against:
etel3rdparty.libCapability require:
CAPABILITY ReadDeviceData
IMSI_Getter.cpp
#include "Imsi_Getter.h" //LP: added #include for Imsi_Getter.h header file
CImsiReader* CImsiReader::NewL(MImsiObserver* aObserver)
{
CImsiReader* self = NewLC(aObserver);
CleanupStack::Pop(self);
return self;
}
CImsiReader* CImsiReader::NewLC(MImsiObserver* aObserver)
{
CImsiReader* self = new (ELeave) CImsiReader(aObserver);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CImsiReader::CImsiReader(MImsiObserver* aObserver)
:CActive(0),iObserver(aObserver),iImsiV1Pkg(iImsiV1)
{
}
CImsiReader::~CImsiReader()
{
Cancel();
delete iTelephony;
}
void CImsiReader::ConstructL(void)
{
CActiveScheduler::Add(this);
iTelephony = CTelephony::NewL();
iTelephony->GetSubscriberId(iStatus,iImsiV1Pkg);
SetActive();
}
void CImsiReader::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetSubscriberIdCancel);
}
void CImsiReader::RunL()
{
//LP: added ";" and replaced iTelephony with iObserver
iObserver->GotIMSIL(iImsiV1.iSubscriberId,iStatus.Int());
}
IMSI_Getter.h
#include <Etel3rdParty.h>
class MImsiObserver
{
public: // New methods
virtual void GotIMSIL(const TDesC& aIMSI, TInt aError) = 0;
};
class CImsiReader : public CActive
{
public:
static CImsiReader* NewL(MImsiObserver* aObserver);
static CImsiReader* NewLC(MImsiObserver* aObserver);
~CImsiReader();
protected:
void DoCancel();
void RunL();
private:
CImsiReader(MImsiObserver* aObserver);
void ConstructL(void);
private:
MImsiObserver* iObserver;
CTelephony* iTelephony;
CTelephony::TSubscriberIdV1 iImsiV1;
CTelephony::TSubscriberIdV1Pckg iImsiV1Pkg;
};
Example Code
See Also
- Reading IMSI in 3rd edition -Synchronously
- IMSI on Wikipedia
- Online tool to analyze IMSI
- Get the IMEI, IMSI, CellId etc., synchronously on 3.x devices (Blog no longer available, content reproduced below:)


05 Sep
2009
The IMSI number is used to identify the SIM card. Tracking this card number will help you track - say any SIM change event. This code example nicely illustrates the use of CTelephony API to retrieve the IMSI number from the SIM card.
Chen2011 -
For double SIM cards, how can get IMSI information of a SIM card ?chen2011 12:42, 27 March 2012 (EEST)