Many Nokia Store distributed applications have "Buy full version" or "Check our other apps" functionality which require opening of Nokia Store client app on certain page. Usually such functions could be implemented by opening store url in system browser. Browser will automatically redirect user to Nokia Store client and open required content or author page in it. But that approach has some disadvantages:
1. Bad (well, not perfect) user experience. Web browser acts as a mediator between your app and Store client. And it looks unnecessary.
2. SwEvent capability should be declared in your .pro file. Without it your openUrl() request will be ignored by the system in case system browser is already running. That’s a kind of security mechanism inherited from Symbian C++ and aimed to prevent malware from webpage urls spoofing while user browse the web. Some developers don’t know about that and suppose their openUrl() works in all cases. Some forget to add SwEvent declaration before submitting sis in Store (SwEvent require signing by Developer or Ovi certificates, so if you need only User granted capabilities for other features you can use more convenient self-generated certificate during development) .
At the same time there are one advantage: That more or less official method, so you can expect some compatibility here. There is no any guarantees that the method I describe below will work for all future Store versions. But i hope it will.
Well, so we have the indirect method, which looks like that:
#include <QDesktopServices>
// Opens Angry birds page in Store client app
QDesktopServices::openUrl(QUrl(QString("http://store.nokia.mobi/content/61009")));
// Opens author’s page in Store client app
QDesktopServices::openUrl(QUrl(QString("http://store.nokia.mobi/publisher/RovioMobile/")));
//Here you will need SwEvent capability declaration in case browser is already open
Now we want open Store client directly without system browser use.
After shot investigation of the page used for user redirection I find out that it launches ovistore_2002D07F.exe and passes whole original url to it as a parameter. Its worth to say for Symbian C++ guys that app’s UID3 is obviusly 2002D07F and you may not read further bcs you can implement even more flexible and reliable launcher with Symbian C++.
For others I wrote a class that launches the Store directly by the application name and in case something goes wrong (for example, executable was renamed) fall back to the old reliable web browser url opening. The demo app sources and sis are attached.
Some code snippets:
storelauncher.h
#include <QObject>
#include <QProcess>
class QStoreLauncher : public QObject
{
Q_OBJECT
public:
explicit QStoreLauncher(QObject *parent = 0);
void LaunchNokiaStore(QString);
private slots:
void processError(QProcess::ProcessError error);
private:
QProcess *myProcess;
QString arguments;
};
storelauncher.cpp
#include <QDesktopServices>
#include <QUrl>
#include "storelauncher.h"
QStoreLauncher::QStoreLauncher(QObject *parent) :
QObject(parent)
{
myProcess = new QProcess(this);
QObject::connect(myProcess, SIGNAL(stateChanged(QProcess::ProcessState)),
this, SLOT(stateChanged(QProcess::ProcessState)));
}
void QStoreLauncher::LaunchNokiaStore(QString params)
{
arguments = params;
const QString NokiaStoreLauncherApp ("ovistore_2002D07F");
myProcess->start(NokiaStoreLauncherApp, arguments.split(QString("\n")));
}
void QStoreLauncher::processError(QProcess::ProcessError error)
{ // Hey, something goes wrong
switch (error)
{
case QProcess::FailedToStart:
case QProcess::Crashed:
case QProcess::Timedout:
case QProcess::ReadError:
case QProcess::WriteError:
case QProcess::UnknownError:
{
//Here you will need SwEvent capability declaration in case browser is already open
QDesktopServices::openUrl(QUrl(arguments));
break;
}
default:
{
break;
}
}
}
Usage:
QStoreLauncher launcher(this);
// Opens author's page in Store client app
launcher->LaunchNokiaStore(QString("http://store.nokia.mobi/publisher/RovioMobile/"));
// Opens Angry birds page in Store client app
launcher->LaunchNokiaStore(QString("http://store.nokia.mobi/content/61009"));
So as you see it’s pretty simple. Tested with my N8-00 Anna and Store v3.18.
I suppose url host may vary. For example store.ovi.mobi, store.nokia.com or store.ovi.com. It’ll work for all, but didn’t check much.
And no – I don’t know if Store client supports or will support any other url formats, for ex. reviews page opening etc.
NokiaStoreLauncher.sis
NokiaStoreLauncher.zip
