2016-04-13 2 views
1

別のアプリケーションにプッシュするために、異なるアプリケーションIDを持つ以下のコードを使用して2つの別々の呼び出しを行うことです。そして、これをレール上のルビーでやりたい。Pushwoosh - Rubyで2つの異なるアプリケーションプッシュ通知をする方法

auth_hash = { auth: '55555-5555', application: '1234zxcvb' } 
Pushwoosh.PushNotification.new(auth_hash).notify_devices(message, devices, other_options) 

をこのエラーが出る:

undefined method `PushNotification' for Pushwoosh:Module 

ところで、私はそれだけでプッシュする作品として、初期化子の例を使用していけない、私はRuby on Railsをにこのコードを挿入しかし

、 1つのアプリに私はpushwooshを使用して2つの異なるアプリにプッシュしたい。

答えて

1

この実装は機能しています。あなたはデバイスのparamに行くオブジェクトの種類を教えていただけますか?代わりに「Pushwoosh.PushNotification.new」

def notify_app1 
    auth_hash = { auth: 'your_auth_key', application: 'app-id-2' } 
    Pushwoosh::PushNotification.new(auth_hash).notify_all('', {}) 
end 

def notify_app2 
    auth_hash = { auth: 'your_auth_key', application: 'app-id-2' } 
    Pushwoosh::PushNotification.new(auth_hash).notify_all('', {}) 
end 
0

gemのreadmeによるとPushwoosh.configureはRailsアプリケーションでのみ使用でき、Pushwoosh.PushNotification.newでは使用できません。ただし、プッシュ通知を送信するたびにPushwooshを初期化できます。例:

def configure_pushwoosh(app_id, auth_token) 
    Pushwoosh.configure do |config| 
    config.application = app_id 
    config.auth = auth_token 
    end 
end 

configure_pushwoosh('55555-5555', '1234zxcvb') 
Pushwoosh.notify_devices(message, devices, other_options) 

configure_pushwoosh('11111-1111', 'asda1231231') 
Pushwoosh.notify_devices(message, devices, other_options) 
+0

こんにちは@Maximの「Pushwoosh :: PushNotification.new」を使用する必要がありますかそれは、['1232341234123'、123412341234]のようなデバイストークンの配列ですか? - ありがとうございます – jlstr

+1

@Joseはい、文字列の配列。たとえば、次のように '[ "edjQ5DF9nWQ:APA91bH3qZ6DqD2OIQNQ5eET7cxdXtEu2CnZluBg4ZZo7hdJZuHdC3xf6pRVA9OhsUme4gqqN32K-dHb7pqFKjAM0j9aqzNGxbSJEl1QtCbAZ94cTxuDDxUhyloDIJ7i6S9A7HJHRsOq"]あなたの答えマキシムのための' –

+0

多くの感謝! – jlstr

関連する問題