Forums

 
ForumForumMainstream Foru...Mainstream Foru...BugsBugsBeta2 - isMobile doesnBeta2 - isMobile doesn't seem to detect mobiles...
Previous Previous
 
Next Next
New Post
 1/8/2008 9:09 AM
 

I can certainly assist in this matter - support for mobile devices is critical to me. It would also be wicked if it could set the theme depending on what device it is - for example there might be a blackberry specific theme or one for iPhones. I will have a rummage in the code see what i can come up with

Still waiting on getting my Blackberry reconnected - RIM seems to expect payment for their services... whatever next?
I have an iPhone as well but that's at home at the moment..

New Post
 1/9/2008 3:50 AM
 
 Modified By Simon Probert  on 1/9/2008 4:55:03 AM

After paying the charge my Blackberry now works again... and returned the following

User Agent: BlackBerry8800/4.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/123
Browser:Unkown

Version:0.0
Platform: Unknown
Type: Unkown

IsMobile?:
False
isMobileDevice?:false

And the iPhone returned

User Agent: Mozilla /5.0 iPhone something or other
Browser:AppleMac - Safari

Version:0.0
Platform: Unknown
Type: Desktop

IsMobile?:
False
isMobileDevice?:false

So what I can deduce so far is that Request.Browser.Capabilities["isMobileDevice"] is probably not the best way of sniffing a browser - there is another class class in system.web.mobile.MobileCapabilities which promises to have better results, but I haven't figured it out yet. One option is to parse the user agent string - but that means you need to keep up with the ever changing world of mobile devices... An alternative quick hack would be to set the flag on Platform...

eg

If platform = WinCE then isMobile = True
If platform = Unknown then isMobile = True ( Assumes Unknowns are Mobiles )

otherwise just carry on as normal...

But that's not particularily elegant - so I will take a closer look at http://msdn2.microsoft.com/en-us/library/system.web.mobile.mobilecapabilities.aspx

 

 

New Post
 1/9/2008 4:44 AM
 
 Modified By Simon Probert  on 1/9/2008 10:35:33 AM

Ok so here's the quick hack change the following at around line 358 in _Controls/Utils.cs

public static bool IsMobileDevice
{
   get
         {
         // return Sql.ToBoolean(HttpContext.Current.Request.Browser.Capabilities["isMobileDevice"]);
         // 09/01/2008 Spacecowboy. A little hack to detect WinCE or Unknown platforms - assumes mobile device being used
         
string PlatformCheck;
         PlatformCheck = (
HttpContext.Current.Request.Browser.Platform);
         
if (PlatformCheck == "WinCE"){ return true; }
         if (PlatformCheck == "Unknown"){return true;}
         return false;
         }
}

Obvously I compressed it a bit to make it more readable - Works for all WinCE devices and Unkown captures Blackberries and iPhones.

[added]

simply change the false at the end to true and you see the mobile theme through a normal browser - this is pretty handy for designing the mobile theme because lets face it fiddling around with mobile phones to view web pages is... well.. annoying. Far easier to develop in a regular browser and then start using mobiles for proper testing. I've also noticed a few javascript errors being cause by the new theme that way. Nothing serious though - but as everybody know mobile templates need to super lightweight and any errors slow it down. Might even see if it's not possible to remove javascript alltogether from the mobile theme...

it's pretty easy now to switch off stuff you don't need in the mobile template in the main codebase.

For example users/login.aspx throws a "showLeftColum is not defined error" when in mobile theme so to cure that you simply wrap the offending javascript in a bit of code thus:

<% if (!this.IsMobile){%>

<script type="text/javascript">
   window.onload = function()
   {
   
set_focus();
   
showLeftCol(false, false);
   }
</script>

<% } %>

 

 

[/added]

 

 

New Post
 1/9/2008 5:00 PM
 
 Modified By Support  on 1/9/2008 6:01:48 PM

Microsoft has created a framework to handle browser detection, and it would be a mistake to circumvent it.  For one thing, the browser caps files are located at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\Browsers.  There is no blackberry in the list, but you can find a published file at http://www.codeproject.com/KB/aspnet/BlackberryASPNET.aspx.

.NET 2.0 allows you to place these browser files inside the application under the App_Browsers folder.  This is what we will do, but you will have to test it as we do not own a blackberry.

Also, please research why your system does not automatically detect the PocketPC. Ours works just fine, as does our Smartphone.  Maybe you need to create a new browser file for the older PocketPC.

New Post
 1/9/2008 8:49 PM
 

We have added two browser files to the App_Browsers folder to identify a BlackBerry and an iPhone.  These new files will be in the next build and they are available in Vault at $/SplendidCRM/Open/Web2.0/App_Browsers/. You can login as guest/guest and get them now.

Previous Previous
 
Next Next
ForumForumMainstream Foru...Mainstream Foru...BugsBugsBeta2 - isMobile doesnBeta2 - isMobile doesn't seem to detect mobiles...