How to save text and display using Touch Screen Keyboard

Hey guys,

A user clicks a button and the iphone keyboard pops up. They are prompted to enter their player’s name. I want to be able to save the text they enter in Player Prefs so I can grab their name throughout the game. Seemingly simple but nothing is being saved. After the user taps “return” or “done” on the keyboard there is nothing saved but an empty string in the PlayerPrefs. Here’s the code:

private string playerName;

void NamePlayer() {

        TouchScreenKeyboard keyboard;
		keyboard = TouchScreenKeyboard.Open(playerName, TouchScreenKeyboardType.Default, false, false, false, false, "Enter Name");
		if (keyboard.active) 
		playerName = keyboard.text;
		PlayerPrefs.SetString("PlayerName",playerName);
}

This is what I wrote to use the iPhone keyboard :

#pragma strict

public var kBoardString : String = "";

private var tempString : String = "";
private var keyboard : iPhoneKeyboard;
private var iskBoardOpen : boolean = false;

function Update() 
{
	kBoard0();
}

function kBoard0()
{
	// keyboard = iPhoneKeyboard.Open( tempName : String, iPhoneKeyboardType.Default, Auto-Correct, Multi-Line, Secure, Alert, "Text Placeholder" );
	
	if ( !iskBoardOpen ) 
	{
		keyboard = iPhoneKeyboard.Open( tempString, iPhoneKeyboardType.Default, false, false, false, false, "Default Keyboard" );
		iskBoardOpen = true;
	}
	
	if ( keyboard.done ) 
	{
		kBoardString = keyboard.text;
		tempString = "";
		iskBoardOpen = false;
	}
	else
	{
		kBoardString = keyboard.text;
	}
}