Detecting a changed SIM card

When a user changes a SIM card in a BlackBerry device, the BlackBerry 10 Native SDK automatically destroys the channel. Our sample application removes the user from the database if necessary, and unsubscribes the user from the Push Initiator if you chose to subscribe with Push Service SDK when you configured our sample application. Our sample application also removes all existing push messages and notifications in the BlackBerry Hub that are associated with the user. Our sample application performs these actions for security purposes because a new user might be using the device, and that user shouldn't receive push messages that were intended for the previous user. In your application, you should authenticate all new users.

Our sample application also displays a dialog box that asks if the user wants to register again. Our application performs one of the following actions depending on the answer that the user provides:

  • If the user selects No in the dialog box, our sample application closes the dialog box.
  • If the user selects Yes and you're not subscribing with the Push Service SDK, our sample application tries to create a channel.
  • If the user selects Yes and you're subscribing with the Push Service SDK, our sample application displays the Register dialog box where the user must type a user name and password.

The onSimChanged() function is implemented in the AppHeadless class in our headless application code. Our headless application connects a slot to the simChanged signal.

AppHeadless::AppHeadless()
{
// ...
checkConnectResult(QObject::connect(m_pushNotificationService, 
  SIGNAL(simChanged()), this, SLOT(onSimChanged())));
// ...
}

void AppHeadless::onSimChanged()
{
    // Remove the currently registered user (if there is one)
    // and unsubscribe the user from the Push Initiator since
    // switching SIMs might indicate we are dealing with
    // a different user. Also, remove all pushes and push
	// history from the database.
    m_pushNotificationService->handleSimChange(m_pushHandler);

    sendStatusToUI(PUSH_COLLECTOR_SIM_CHANGE);
}

Last modified: 2013-12-21

comments powered by Disqus