Only use the |window| property on the app delegate if it is implemented

|window| is an optional property, so if it is not defined, we use the previous
method of using |keyWindow| instead.