Detecting a changed SIM card

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

The sample application then displays a dialog box asking the user to register. The sample application performs one of the following actions depending on the answer that the user provides:

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

The simChange() function is implemented in the PushReceiver class in the sample application code.

private function simChange(e:PushServiceEvent):void
	// 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.
    // Remove all notifications from the BlackBerry Hub and pushes 
    // displayed on the screen
    noPushesLabel.visible = true;
    var simChangeDialog:AlertDialog = new AlertDialog();
	simChangeDialog.title = "Push Receiver";
	simChangeDialog.message = "The SIM card was changed and,
      as a result, the current user has been unregistered.
      Would you like to re-register?";

private function simChangeDialogClicked(event:Event):void
	if ( == 1) {
        // The "Yes" button was clicked, show the register 
        // dialog

If you want to perform a different action when a user changes a SIM card, you can register an event listener and create an event handler that performs the appropriate action.