简体   繁体   中英

Android - CloudPush not working on production

I have this problem, I am using the CloudPush module to retrieve the token in my app, and in all the test work ok, but when I upload the app to the store and the people download it, the app just doesnt retrieve the token, I notice this error every time I create a cloudPush instance.

[INFO] :   *** Vamos a validar
[INFO] :   *** CREATE INSTANCE OF CLOUDHPUSH!!!!!!!!!
[ERROR] :  TiHTTPClient: (TiHttpClient-10) [30,1458] HTTP Error     (java.io.IOException): 404 : Not Found
[ERROR] :  TiHTTPClient: java.io.IOException: 404 : Not Found
[ERROR] :  TiHTTPClient:    at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1283)
[ERROR] :  TiHTTPClient:    at java.lang.Thread.run(Thread.java:818)
[INFO] :   *** BEFORE SINGLE CALL BACK
[INFO] :   *** BEFORE retrieveDeviceToken
[INFO] :   Choreographer: Skipped 46 frames!  The application may be doing too much work on its main thread.
[INFO] :   art: Background partial concurrent mark sweep GC freed 3578(221KB) AllocSpace objects, 0(0B) LOS objects, 24%% free, 15MB/20MB, paused 5.096ms total 51.635ms
[ERROR] :  GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
[WARN] :   W/InstanceID/Rpc: Found 10076
[INFO] :   Device Token: APA91bHU56CLjjEcMyroqoWH3VJFCSqBIKT2A7Amctdjiuw1Rk5a8upzfJJotfIUTh6619Wx-g7OG2rTMuceHm4r8ASz41K_bEYG1vh2q3_mwTM0ERbij4asAB4IPKIUkEZQCW9HcAFL

My code is:

    var self = Ti.UI.createWindow({
    orientationModes: [ Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT],
    backgroundColor: params.color6,
    backgroundImage: "/images/fondo.jpg",
        navBarHidden:true,
        exitOnClose:true,
        fullscreen:true
    });
    self.addEventListener("open", function(){

     Ti.API.info("*** Vamos a validar");
     if(Ti.Platform.osname=='android'){

          Ti.API.info("*** CREATE INSTANCE OF CLOUDHPUSH!!!!!!!!!");
         var CloudPush = require('ti.cloudpush');
         Ti.API.info("*** BEFORE SINGLE CALL BACK");
         CloudPush.setSingleCallback( true );
         Ti.API.info("*** BEFORE retrieveDeviceToken");
         CloudPush.retrieveDeviceToken({
             success: function deviceTokenSuccess(e) {
                 var token = e.deviceToken;
                 Ti.API.info('Device Token: ' + e.deviceToken);
                 Utiles.RegistrarEnServidor( token );
             },
             error: function deviceTokenError(e) {
                 Ti.API.info("*** Failed to register for push");
             }
         });

I dont know what I am doing wrong... in testing all works fine, but the app in the play store doesn't work, the token never gets retrieved.

Titanium Appcelerator Studio build : 4.9.1.201707200100
SDK : 6.1.2GA
CloudPush : 4.0.3

In order to make your push work you need to take note of few things, let see them step by step :

tiapp.xml

<!-- Property keys for Arrow Push (required) -->
<property name="acs-api-key-development" type="string">YOUR DEVELOPMENT API KEY HERE</property>
<property name="acs-api-key-production" type="string">YOUR PRODUCTION API KEY HERE</property>
<property name="acs-api-key" type="string">YOUR API KEY HERE</property>

I hope you have added the correct keys in the correct slots. You also need to add you push service api URL in tiapp.xml

<ti:app>
    <property name="acs-push-api-url-production">https://api-prod.fooinc.com</property>
    <property name="acs-push-api-url-development">https://api-dev.fooinc.com</property>
</ti:app>

For notification/Badegs in tiapp.xml

<property name="acs-grouped-notification-message-development" type="string">You have $number$ unread messages.</property>
<property name="acs-grouped-notification-message-production" type="string">You have $number$ unread messages.</property>
-or-
<property name="acs-grouped-notification-message" type="string">You have $number$ unread messages.</property>

Also make key value for the same in your i18n folder for multiLang

According to the code you have provided all seems to be fine so nothing is wrong with code as per as my guess is.

Certificates and Provisioning Profile (iOS only)

You need to create proper provisioning Profile and Certificate for Production/Development, also you need create on .PEM file that will help you send/receive the push notification for specific device and App, that's where the registration of device works. So you need to be sure that you have created the Certificates correctly. You can have a look at the procedure to create the Certificate and Provisioning Profile from below link : https://www.raywenderlich.com/156966/push-notifications-tutorial-getting-started

I hope this helps you resolve the problem. Let me know if you have further issue after this.

Good Luck and Cheers

Ashish Sebastian

I solve the problem with the module: PushClient

I leave it here if some one has the same problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM