Using pubnub with android geting android.permission.INTERNET error.

Hi, I am attempting to run the hello world app on an Android.   I get an error message pubnub.lua:583:
java.lang.SecurityException:
Neither user 100018 nor current process has android.permission.INTERNET. 
 

I am including my build.config and the Helloworld App code below.  The app works fine until I begin using my pubnub keys.

Here is the Helloworld App Code.

require “pubnub”

multiplayer = pubnub.new({
    publish_key   = “my_publish_key”,
    subscribe_key = “my_subscribe_key”,
    secret_key    = nil,
    ssl           = nil,
    origin        = “pubsub.pubnub.com
})

multiplayer:subscribe({
    channel  = “hello-world-corona”,
    callback = function(message)
        print(message.msgtext)
    end,
    errorback = function()
        print(“Oh no!!! Dropped 3G Conection!”)
    end
})

function send_a_message(text)
    multiplayer:publish({
        channel = “hello-world-corona”,
        message = { msgtext = text }
    })
end

function send_hello_world()
    send_a_message(“Hello World!!!”)
end

timer.performWithDelay( 500, send_hello_world, 10 )
send_hello_world()

Here is my build.config:

build.settings:

settings =
{
   android =
   {
        usesPermissions = {
          “android.permission.INTERNET”,
          “android.permission.WRITE_EXTERNAL_STORAGE”,

          “android.permission.ACCESS_NETWORK_STATE”,
          “android.permission.ACCESS_FINE_LOCATION”,
          “android.permission.ACCESS_COARSE_LOCATION”,
          “android.permission.READ_PHONE_STATE”,
        },
        usesFeatures =
        {
            { name = “android.hardware.camera”, required = false },
            { name = “android.hardware.location”, required = true },
            { name = “android.hardware.location.gps”, required = true },
        },
   },
}

Hi Guyduff,

This is uncommon indeed.  Have you tried building from an empty project with no modified permission settings?

PubNub Corona SDK Debugging Publish Events

Make sure to register the error callback to detect problems with your publish call events. Here is an example of a fully featured pubnub.publish({…}) call.


– CALL PUBLISH FUNCTION

function publish( channel, text )
pubnub_obj:publish({
channel = channel,
message = text,
callback = textout,
error = textout
})
end

Full Lua Publish Demo Example:

Use this to test your lua corona app for publishing messages successfully. You will see text output for debugging your code.


– PubNub : Publish Example

require “pubnub”
require “PubnubUtil”

textout = PubnubUtil.textout


– INITIALIZE PUBNUB STATE

pubnub_obj = pubnub.new({
publish_key = “demo”,
subscribe_key = “demo”,
secret_key = nil,
ssl = nil,
origin = “pubsub.pubnub.com
})


– HIDE STATUS BAR

display.setStatusBar( display.HiddenStatusBar )


– CALL PUBLISH FUNCTION

function publish(channel, text)
pubnub_obj:publish({
channel = channel,
message = text,
callback = function® --textout®
end,
error = function® textout®
end
})
end


– MAIN TEST

local my_channel = ‘lua-dsm’


– Publish String

publish(“abcd”, ‘Hello World!’ )


– Publish Dictionary Object

publish(“efgh”, { Name = ‘John’, Age = ‘25’ })


– Publish Array

publish(“ijkl”, { ‘Sunday’, ‘Monday’, ‘Tuesday’ })

I don’t see anything in the simulator at all.  I did start the project over from scratch and tried it without a build.settings file.  Same error when I tried to run the apk file.  After some research I modified the build.config for the android (see below).  The app doesn’t issue the same error message but I am so new to pubnub that I’m not sure where the error messages of the above code you suggested would be seen.  In fact, I feel confident that I’m not using the pubnub.com/console correctly to read from the app messages I’m sending. 

I don’t see it in the corona simulator output window nor anywhere in the app output.  In fact, looking at the above code I’m not sure it outputs anything to the app screen.  I am sure I am missing something obvious here.  Pubnub is the most awesome communication system I have ever seen.  Hopefully I’ll get past this dazed and confused stage.  Does the console enable me to view the messages from the above error testing code you posted?  If not, do you have a very simple html form with a subscribe function with javascript I can execute and display the messages above?  A great starter system would be an html with javascript along with your hello world app that you posted on youtube.  That way its easy to see the basic mechanics.  I’ll be posting huge numbers of messages, like one a second from hundreds and then thousands of devices ultimately.   I just need to get the basics goign before I pass this off to full stack coder.  I just need to send one stream of messages and display the raw data in a web page and then I can go back to focusing on the Corona side of my app and the back end database.

Here is the  build.settings code that doesn’t create a run time on the Android.

   settings =
  {
  android =
     {
      permissions =
          {
              { name = “.permission.C2D_MESSAGE”, protectionLevel = “signature” },
          },
          usesPermissions =
          {
              – Required by the MapView to fetch its contents from the Google Maps servers.
              “android.permission.INTERNET”,
              “android.permission.GET_ACCOUNTS”,
              “android.permission.RECEIVE_BOOT_COMPLETED”,
              “com.google.android.c2dm.permission.RECEIVE”,
              “.permission.C2D_MESSAGE”,

              – Optional permission used to display current location via the GPS.
              “android.permission.ACCESS_FINE_LOCATION”,

              – Optional permission used to display current location via WiFi or cellular service.
              “android.permission.ACCESS_COARSE_LOCATION”,
          },
          usesFeatures =
          {
              – If you set permissions “ACCESS_FINE_LOCATION” and “ACCESS_COARSE_LOCATION” above,
              – then you may want to set up your app to not require location services as follows.
              – Otherwise, devices that do not have location sevices (such as a GPS) will be unable
              – to purchase this app in the app store.
              { name = “android.hardware.location”, required = false },
              { name = “android.hardware.location.gps”, required = false },
              { name = “android.hardware.location.network”, required = false },
          },
     },
  }

Hi Guyduff,

This is uncommon indeed.  Have you tried building from an empty project with no modified permission settings?

PubNub Corona SDK Debugging Publish Events

Make sure to register the error callback to detect problems with your publish call events. Here is an example of a fully featured pubnub.publish({…}) call.


– CALL PUBLISH FUNCTION

function publish( channel, text )
pubnub_obj:publish({
channel = channel,
message = text,
callback = textout,
error = textout
})
end

Full Lua Publish Demo Example:

Use this to test your lua corona app for publishing messages successfully. You will see text output for debugging your code.


– PubNub : Publish Example

require “pubnub”
require “PubnubUtil”

textout = PubnubUtil.textout


– INITIALIZE PUBNUB STATE

pubnub_obj = pubnub.new({
publish_key = “demo”,
subscribe_key = “demo”,
secret_key = nil,
ssl = nil,
origin = “pubsub.pubnub.com
})


– HIDE STATUS BAR

display.setStatusBar( display.HiddenStatusBar )


– CALL PUBLISH FUNCTION

function publish(channel, text)
pubnub_obj:publish({
channel = channel,
message = text,
callback = function® --textout®
end,
error = function® textout®
end
})
end


– MAIN TEST

local my_channel = ‘lua-dsm’


– Publish String

publish(“abcd”, ‘Hello World!’ )


– Publish Dictionary Object

publish(“efgh”, { Name = ‘John’, Age = ‘25’ })


– Publish Array

publish(“ijkl”, { ‘Sunday’, ‘Monday’, ‘Tuesday’ })

I don’t see anything in the simulator at all.  I did start the project over from scratch and tried it without a build.settings file.  Same error when I tried to run the apk file.  After some research I modified the build.config for the android (see below).  The app doesn’t issue the same error message but I am so new to pubnub that I’m not sure where the error messages of the above code you suggested would be seen.  In fact, I feel confident that I’m not using the pubnub.com/console correctly to read from the app messages I’m sending. 

I don’t see it in the corona simulator output window nor anywhere in the app output.  In fact, looking at the above code I’m not sure it outputs anything to the app screen.  I am sure I am missing something obvious here.  Pubnub is the most awesome communication system I have ever seen.  Hopefully I’ll get past this dazed and confused stage.  Does the console enable me to view the messages from the above error testing code you posted?  If not, do you have a very simple html form with a subscribe function with javascript I can execute and display the messages above?  A great starter system would be an html with javascript along with your hello world app that you posted on youtube.  That way its easy to see the basic mechanics.  I’ll be posting huge numbers of messages, like one a second from hundreds and then thousands of devices ultimately.   I just need to get the basics goign before I pass this off to full stack coder.  I just need to send one stream of messages and display the raw data in a web page and then I can go back to focusing on the Corona side of my app and the back end database.

Here is the  build.settings code that doesn’t create a run time on the Android.

   settings =
  {
  android =
     {
      permissions =
          {
              { name = “.permission.C2D_MESSAGE”, protectionLevel = “signature” },
          },
          usesPermissions =
          {
              – Required by the MapView to fetch its contents from the Google Maps servers.
              “android.permission.INTERNET”,
              “android.permission.GET_ACCOUNTS”,
              “android.permission.RECEIVE_BOOT_COMPLETED”,
              “com.google.android.c2dm.permission.RECEIVE”,
              “.permission.C2D_MESSAGE”,

              – Optional permission used to display current location via the GPS.
              “android.permission.ACCESS_FINE_LOCATION”,

              – Optional permission used to display current location via WiFi or cellular service.
              “android.permission.ACCESS_COARSE_LOCATION”,
          },
          usesFeatures =
          {
              – If you set permissions “ACCESS_FINE_LOCATION” and “ACCESS_COARSE_LOCATION” above,
              – then you may want to set up your app to not require location services as follows.
              – Otherwise, devices that do not have location sevices (such as a GPS) will be unable
              – to purchase this app in the app store.
              { name = “android.hardware.location”, required = false },
              { name = “android.hardware.location.gps”, required = false },
              { name = “android.hardware.location.network”, required = false },
          },
     },
  }